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

public class Main {

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(in, out);
        out.close();
    }

    public static class TaskB {
        public void solve(InputReader in, PrintWriter out) {
            String s = in.next();
            int n = s.length();
            int prefA[] = new int[n];
            int prefB[] = new int[n];
            prefA[0] = s.charAt(0) == 'a' ? 1 : 0;
            prefB[0] = s.charAt(0) == 'b' ? 1 : 0;
            for (int i = 1; i < n; i++) {
                prefA[i] = prefA[i - 1] + (s.charAt(i) == 'a' ? 1 : 0);
                prefB[i] = prefB[i - 1] + (s.charAt(i) == 'b' ? 1 : 0);
            }
            int max = 0;
            for (int i = -1; i < n; i++) {
                int amount1 = sum(0, i, prefA);
                for (int j = i; j < n; j++) {
                    int amount2, amount3;
                    if (j > i) {
                        amount2 = sum(i + 1, j, prefB);
                        amount3 = sum(j + 1, n - 1, prefA);
                    } else {
                        amount2 = 0;
                        if (j + 1 == n)
                            amount3 = 0;
                        else
                            amount3 = sum(j + 1, n - 1, prefA);
                    }
                    int curAns = amount1 + amount2 + amount3;
                    max = Math.max(max, curAns);
                }
            }
            out.println(max);
        }

        private int sum(int l, int r, int ar[]) {
            if (l >= ar.length)
                return 0;
            if (l > r)
                return 0;
            if (l == 0)
                return ar[r];
            else
                return ar[r] - ar[l - 1];
        }
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

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