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.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Map.Entry;
import java.util.Scanner;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.Vector;


public class solve {
	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws IOException{
		
		FastScanner sc = new FastScanner();
	    PrintWriter out = new PrintWriter(System.out);
	    String str =sc.nextToken();
	    int n =str.length();
	    int a[]=new int[n];
	    int b[]=new int[n];
	    
	    if(str.charAt(0)=='a')a[0]=1;
	    for(int i=1;i<n;i++){
	    	a[i]=a[i-1];
	    	if(str.charAt(i)=='a')
	    		a[i]++;
	    }
	    if(str.charAt(0)=='b')b[0]=1;
	    for(int i=1;i<n;i++){
	    	b[i]=b[i-1];
	    	if(str.charAt(i)=='b')
	    		b[i]++;
	    }
	    
	    int max=-1;
	    for(int i=0;i<n;i++){
	    	for(int j=i;j<n;j++){
	    		int ans =a[i]-a[0]+a[n-1]-a[j]+b[j]-b[i];
	    		if(str.charAt(j)=='a' || str.charAt(0)=='a')ans++;
	    		if(str.charAt(i)=='b')ans++;
	    		max=Math.max(max, ans);
	    		//System.out.println(b[3]-b[0]);
	    	}
	    }
	    System.out.println(max);
	    
	    
	
	 

	
	}

	
	





}
	



	    	
class pair implements Comparable{
	int x ,y,z;
	pair(int x,int y,int z)
	{
		this.x=x;
		this.y=y;
		this.z=z;
	}
	@Override
	public int compareTo(Object arg0) {
		
		pair u =((pair)arg0);
		
		return -this.z+u.z;
	}
}
 	


	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
	    
  

	  
	   
	    	
	    	
	 
	    
	    
	    		
	  	
	    	
	    	
	 
	 





















class FastScanner {




    BufferedReader br;
    StringTokenizer st;

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

    public FastScanner(String s) {
        try {
            br = new BufferedReader(new FileReader(s));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

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

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

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

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

}