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.util.*;
import java.io.*;
public class Two{

    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    static class Point{
        int x,y,index;
        HashSet<Integer> hs=new HashSet<>();
        Point(int x,int y,int index,HashSet<Integer> hs){
            this.x=x;
            this.y=y;
            this.index=index;
            this.hs=hs;
        }
    }

    static long gcd(long a,long b){
        if(b==0)
            return a;
        return gcd(b,a%b);
    }

    static long pow(long a,long b,long mod){
        if(b==0)
            return 1;
        if(b%2==0){
            long x=pow(a,b/2,mod);
            return (x*x)%mod;
        }
        else{
            return (a*pow(a,b-1,mod))%mod;
        }
    }
/*

    static long com(int n,int r){
        long ans=1;

        long up=fact[n];
        long down=(fact[r]*fact[n-r])%mod;
        long inv=pow(down,mod-2l,mod);
        return (up*inv)%mod;
    }
*/

    static int ax[]={-1,-1,-1,0,0,1,1,1};
    static int ay[]={-1,0,1,-1,1,-1,0,1};

    //static int ax[]={0,1,0,-1};
    //static int ay[]={-1,0,1,0};


    public static void main(String args[])throws IOException{
        //BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        FastReader fr=new FastReader();
        PrintWriter out=new PrintWriter(System.out);
        String str=fr.nextLine();

        int n=str.length();
        char arr[]=new char[n+1];
        for(int i=1;i<=n;i++){
            arr[i]=str.charAt(i-1);
        }
        int left[]=new int[n+1];
        int right[]=new int[n+2];
        int b[]=new int[n+1];
        for (int i = 1; i <=n ; i++) {
            left[i]=left[i-1];
            if(arr[i]=='a'){
                left[i]++;
            }
            b[i]=b[i-1];
            if(arr[i]=='b'){
                b[i]++;
            }
        }

        for(int i=n;i>=0;i--){
            right[i]=right[i+1];
            if(arr[i]=='a'){
                right[i]++;
            }
        }
        /*System.out.println(Arrays.toString(left));
        System.out.println(Arrays.toString(right));
        System.out.println(Arrays.toString(b));*/
        int ans=Integer.MIN_VALUE;
        for(int i=0;i<=n;i++){
            for(int j=n+1;j>i;j--){
                int left_a=left[i];
                int right_a=right[j];
                int l=i+1;
                int r=j-1;
                int b_len=0;
                if(r>=l) {
                    b_len = b[r] - b[l-1] ;
                }
                int len=left_a+right_a+b_len;
                /*if(len==5){
                    System.out.println(i+" "+j);
                }*/
                ans=Math.max(ans,len);
            }
        }
        out.println(ans);
        out.close();
    }
    static void get(char arr[],int ind,String name[],int count[]){
        String str=name[ind];
        for(int i=0;i<=arr.length-str.length();i++){
            if(valid(str,arr,i)){
                count[ind]++;
            }
        }
    }

    static boolean valid(String str,char arr[],int start){
        int ind=start;
        boolean flag=true;
        for(int i=0;i<str.length();i++){
            if(arr[ind]!=str.charAt(i)){
                flag=false;
                break;
            }
            ind++;
        }
        return flag;
    }
}