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.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author khokharnikunj8
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        int[] count;
        char[] ar;

        public int getCountA(int l, int r) {
            if (l > ar.length || r < 0) return 0;
            while (l < 0) l++;
            while (r >= ar.length) r--;
            if (l > r) return 0;
            return count[r] - (l == 0 ? 0 : count[l - 1]);
        }

        public int getCountB(int l, int r) {
            if (l > ar.length || r < 0) return 0;
            while (l < 0) l++;
            while (r >= ar.length) r--;
            while (l > r) return 0;
            return r - l + 1 - (count[r] - (l == 0 ? 0 : count[l - 1]));
        }

        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            ar = in.scanString().toCharArray();
            count = new int[ar.length];
            for (int i = 0; i < ar.length; i++) {
                if (i != 0) count[i] += count[i - 1];
                count[i] += (ar[i] == 'a' ? 1 : 0);
            }
            int ans = Integer.MAX_VALUE;

            for (int i = -1; i <= ar.length; i++) {
                for (int j = i + 1; j <= ar.length; j++) {
                    ans = Math.min(ans, getCountB(0, i) + getCountA(i + 1, j - 1) + getCountB(j, ar.length));
                }
            }
            out.println(ar.length - ans);
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public String scanString() {
            int c = scan();
            if (c == -1) return null;
            while (isWhiteSpace(c)) c = scan();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = scan();
            } while (!isWhiteSpace(c));
            return res.toString();
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}