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 java.math.*;

public class utkarsh {

    InputStream is;
    PrintWriter out;
    
    long maxl = (long) 4e18, mod = (long)1e9 + 7L;
    
    void solve(){
        //Enter code here utkarsh
        String s = ns();
        int i, j, x, y, ans, n = s.length();
        int d[] = new int[n+10];
        char dp[] = new char[n+10];
        char c;
        j = 0;
        for(i = 0; i < n; i++){
            c = s.charAt(i);
            if(c == 'a'){
                x = 1;
                while(i < n-1 && s.charAt(i+1) == 'a'){
                    i++;
                    x++;
                }
                dp[j] = 'a';
                d[j++] = x;
            }else{
                x = 1;
                while(i < n-1 && s.charAt(i+1) == 'b'){
                    i++;
                    x++;
                }
                dp[j] = 'b';
                d[j++] = x;
            }
        }
        
        //for(i = 0; i < j; i++)  out.println(dp[i] +" "+ d[i]);
        x = 0;
        int a[] = new int[j+100];
        for(i = j+1; i >= 0; i--){
            if(dp[i] == 'a')    x += d[i];
            a[i] = x;
        }
        ans = x = y = 0;
        for(i = 0; i < j; i++){
            if(dp[i] == 'a')    x+= d[i];
            else{
                y = 0;
                for(int k = i; k < j; k += 2){
                    y += d[k];
                    ans = Math.max(ans, x + y + a[k]);
                    //out.println(x +" "+ y +" "+ a[k] +" "+ k);
                }
            }
            ans = Math.max(ans, x);
        }
        out.println(ans);
    }
    
    long modpow(long base, long exp, long modulus) { base %= modulus; long result = 1L; while (exp > 0) { if ((exp & 1)==1) result = (result * base) % modulus; base = (base * base) % modulus; exp >>= 1; } return result;
    }
    
    public static void main(String[] args) { new utkarsh().run();
    }
    void run(){ is = System.in; out = new PrintWriter(System.out); solve(); out.flush();
    }
    
    byte input[] = new byte[1024];
    int len = 0, ptr = 0;
    
    int readByte(){ if(ptr >= len){ ptr = 0; try{ len = is.read(input); }catch(IOException e){ throw new InputMismatchException(); } if(len <= 0){ return -1; } } return input[ptr++];
    }
    boolean isSpaceChar(int c){ return !( c >= 33 && c <= 126 ); 
    }
    int skip(){ int b = readByte(); while(b != -1 && isSpaceChar(b)){ b = readByte(); } return b;
    }
    
    char nc(){ return (char)skip();
    }
    String ns(){ int b = skip(); StringBuilder sb = new StringBuilder(); while(!isSpaceChar(b)){ sb.appendCodePoint(b); b=readByte(); } return sb.toString();
    }
    int ni(){ int n = 0,b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } if(b == -1){ return -1; } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    long nl(){ long n = 0L; int b = readByte(); boolean minus = false; while(b != -1 && !( (b >= '0' && b <= '9') || b == '-')){ b = readByte(); } if(b == '-'){ minus = true; b = readByte(); } while(b >= '0' && b <= '9'){ n = n * 10 + (b - '0'); b = readByte(); } return minus ? -n : n;
    }
    double nd(){ return Double.parseDouble(ns());
    }
    float nf(){ return Float.parseFloat(ns());
    }
    int[] na(int n){ int a[] = new int[n]; for(int i = 0; i < n; i++){ a[i] = ni(); } return a;
    }
    char[] ns(int n){ char c[] = new char[n]; int i,b = skip(); for(i = 0; i < n; i++){ if(isSpaceChar(b)){ break; } c[i] = (char)b; b = readByte(); } return i == n ? c : Arrays.copyOf(c,i);
    }
}