Problem: One day Nikita found the string containing letters "a" and "b" only. 

Nikita thinks that string is beautiful if it can be cut into 3 strings (possibly empty) without changing the order of the letters, where the 1-st and the 3-rd one contain only letters "a" and the 2-nd contains only letters "b".

Nikita wants to make the string beautiful by removing some (possibly none) of its characters, but without changing their order. What is the maximum length of the string he can get?

Input

The first line contains a non-empty string of length not greater than 5 000 containing only lowercase English letters "a" and "b". 

Output

Print a single integer — the maximum possible size of beautiful string Nikita can get.

Examples

Input

abba


Output

4

Input

bab


Output

2

Note

It the first sample the string is already beautiful.

In the second sample he needs to delete one of "b" to make it beautiful.

Solution (in JAVA):

Solution:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
 
public class Solution {
	public static void main(String[] args) {
		InputReader in = new InputReader();
		PrintWriter out = new PrintWriter(System.out);
		Thread th = new Thread(null, new Runnable(){public void run(){new Task1().solve(in, out);}},"Task1",1<<25);
		try{
			th.start();
			th.join();
		} catch(InterruptedException e){}
		out.close();
	}

	static class Task1 {
		static final int MAX = 26;
		Integer[][] dp;
		public void solve(InputReader in, PrintWriter out){ 
			String s = in.next();
			int n = s.length();
			dp = new Integer[n+1][4];
			out.println(knap(s, 0, 0));
		}

		int knap(String s, int i, int state){
			if(i==s.length() || state==3) return 0;

			if(dp[i][state]!=null) return dp[i][state]; 

			if(s.charAt(i)=='a'){
				if(state==0){
					return dp[i][state] = 1+knap(s, i+1, state);
				} else if(state==1){
					return dp[i][state] = Math.max(1+knap(s, i+1, 2), knap(s, i+1, 1));
				} else if(state==2){
					return dp[i][state] = 1+knap(s, i+1, state);
				}
			} else if(s.charAt(i)=='b'){
				if(state==0){
					return dp[i][state] = Math.max(1+knap(s, i+1, 1), knap(s, i+1, 0));
				} else if(state==1){
					return dp[i][state] = 1+knap(s, i+1, 1);
				} else if(state == 2){
					return dp[i][state] = knap(s, i+1, state);
				}
			}

			return dp[i][state] = knap(s, i+1, state);
		}


		long expo(long a, long b, long MOD){
			long result = 1;
			while (b>0){
				if (b%2==1) result=(result*a)%MOD;
				b>>=1;
				a=(a*a)%MOD;
			}
			return result%MOD;
		}
	}
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader() {
			reader = new BufferedReader(new InputStreamReader(System.in));
			tokenizer = null;
		}
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			String s=null;
			try{
				s = reader.readLine();
			} catch(IOException e){
				throw new RuntimeException(e);
			}
			return s;
		}
		public String nextParagraph() {
			String line=null;
			String ans = "";
			try{
				while ((line = reader.readLine()) != null) {
				ans += line;
				}
			} catch(IOException e){
				throw new RuntimeException(e);
			}
			return ans;
		}
	}
}