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.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;


public class Partition {
    
    static StringTokenizer st;
    static BufferedReader sc;
    static PrintWriter pw;
    
    public static void main(String args[]) throws Exception {
        sc = new BufferedReader(new InputStreamReader(System.in));
        pw = new PrintWriter(new BufferedWriter(new OutputStreamWriter(
            System.out)));
        String name = next();
        int [] cntA = new int[name.length()+1];
        int [] cntB = new int[name.length()+1];
        cntA[0]=0;
        cntB[0]=0;
        int max=0,count1=0,count2=0;
        for (int i=0;i<name.length();i++) {
        	if (name.charAt(i)=='a') {
        		count1++;
        	}
        	if (name.charAt(i)=='b') {
        		count2++;        		
        	}
    		cntA[i+1]=count1;
    		cntB[i+1]=count2;
        }
        for (int i=1;i<=name.length();i++) {
        	for (int j=i;j<=name.length();j++) {
        		count1 = cntA[name.length()]-cntA[j-1]+cntA[i-1]+cntB[j]-cntB[i-1];
        		max = Math.max(max, count1);
        	}
        }
       pw.println(max);        
       pw.close();
        
    }
    
    public static boolean istPalindrom(char[] word){
        int i1 = 0;
        int i2 = word.length - 1;
        while (i2 > i1) {
            if (word[i1] != word[i2]) {
                return false;
            }
            ++i1;
            --i2;
        }
        return true;
    }
    
    private static int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    private static long nextLong() throws IOException {
        return Long.parseLong(next());
    }

/*  private static double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
*/
    private static String next() throws IOException {
        while (st == null || !st.hasMoreTokens())
            st = new StringTokenizer(sc.readLine());
        return st.nextToken();
    }


}