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.*;
import java.util.*;
import static java.lang.Math.*;

public class B{
	
	static class shit{
		char c;
		int cnt;
		shit(char a, int b){
			c=a;
			cnt=b;
		}
	}
	static List<shit> a;
	static int[][] dp;
	
	static int solve(int i, int v) {
		if (i >= a.size()) return 0;
		if (dp[i][v] == -1) {
			dp[i][v]=0;
			dp[i][v]=solve(i+1,v);
			if (v != 2) {
				dp[i][v] = max(dp[i][v], solve(i,v+1));
			}
			if (v == 0) {
				if (a.get(i).c == 'a') {
					dp[i][v] = max(dp[i][v], solve(i+1,v+1) + a.get(i).cnt); 
					dp[i][v] = max(dp[i][v], solve(i+1,v) + a.get(i).cnt);
				}
			}
			else if (v==1) {
				if (a.get(i).c == 'b') {
					dp[i][v] = max(dp[i][v], solve(i+1,v+1) + a.get(i).cnt); 
					dp[i][v] = max(dp[i][v], solve(i+1,v) + a.get(i).cnt);
				}

			}
			else {
				if (a.get(i).c == 'a') {
					dp[i][v] = max(dp[i][v], solve(i+1,v) + a.get(i).cnt);
				}
			}
		}
		return dp[i][v];
	}
	
	public static void main(String[] args) throws IOException {
		// br = new BufferedReader(new FileReader(".in"));
		// out = new PrintWriter(new FileWriter(".out"));
		//new Thread(null, new (), "peepee", 1<<28).start();
		char[] c = read().toCharArray();
		char cur = c[0];
		int cnt = 1;
		a = new ArrayList<shit>();
		for (int i =1 ; i <c.length; i++) {
			if (c[i] != cur) {
				a.add(new shit(cur,cnt));
				cnt=1;
			}
			else cnt++;
			cur = c[i];
		}
		a.add(new shit(cur,cnt));
		dp = new int[a.size()][3];
		for (int[] x: dp) Arrays.fill(x, -1);
		out.println(solve(0,0));
		out.close();
	}
	
	static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	static StringTokenizer st = new StringTokenizer("");
	static String read() throws IOException{return st.hasMoreTokens() ? st.nextToken():(st = new StringTokenizer(br.readLine())).nextToken();}
	static int readInt() throws IOException{return Integer.parseInt(read());}
	static long readLong() throws IOException{return Long.parseLong(read());}
	static double readDouble() throws IOException{return Double.parseDouble(read());}
	
}