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.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.StringTokenizer;

public class P {
	static char[] s;
	static int[][] dp;
	static int N;

	static int solve(int status, int cur) {

		if (cur == N)
			return 0;
		if (dp[status][cur] != -1)
			return dp[status][cur];

		int ret = 0;
		if (status == 0) {

			if (s[cur] == 'a') {
				ret = Math.max(ret, Math.max(solve(status, cur + 1) + 1, solve(1, cur + 1)));
			} else {
				ret = Math.max(ret, Math.max(solve(status, cur + 1), solve(1, cur + 1) + 1));
			}

		} else if (status == 1) {
			if (s[cur] == 'a') {
				ret = Math.max(ret, Math.max(solve(status, cur + 1), solve(2, cur + 1) + 1));
			} else {
				ret = Math.max(ret, Math.max(solve(status, cur + 1) + 1, solve(2, cur + 1)));
			}
		} else {
			if (s[cur] == 'a') {
				ret = solve(status, cur + 1) + 1;
			} else
				ret = solve(status, cur + 1);
		}

		return dp[status][cur] = ret;

	}

	public static void main(String[] args) throws IOException {
		// Scanner sc = new Scanner("input.txt");
		// PrintWriter out = new PrintWriter("output.txt");
		Scanner sc = new Scanner(System.in);
		String ss = sc.next();
		ArrayList<Character> a = new ArrayList<Character>();
		for (int i = 0; i < ss.length(); ++i)
			if (ss.charAt(i) == 'a' || ss.charAt(i) == 'b')
				a.add(ss.charAt(i));
		s = new char[a.size()];
		for (int i = 0; i < a.size(); ++i)
			s[i] = a.get(i);
		N = s.length;
		dp = new int[3][N + 1];
		for (int i = 0; i < 3; ++i)
			Arrays.fill(dp[i], -1);
		System.out.println(solve(0, 0));
		// out.flush();
		// out.close();
	}

	static class Scanner {
		StringTokenizer st;
		BufferedReader br;

		public Scanner(InputStream s) {
			br = new BufferedReader(new InputStreamReader(s));
		}

		public Scanner(String file) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(file));
		}

		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

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

}