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

public class P877B {
    private static class HpReader {
        private BufferedReader in;
        private String containingDirPath;

        private static int ivl(String val) {
            return Integer.parseInt(val);
        }

        private void initAndRedirectInOut(String dir, String inFile, String outFile) throws FileNotFoundException {
            if (dir != null) {
                containingDirPath = dir.endsWith(File.separator) ? dir : dir + File.separator;
                if (isDebug() && inFile != null) System.setIn(new FileInputStream(new File(containingDirPath + inFile)));
                if (isDebug() && outFile != null) System.setOut(new PrintStream(new File(containingDirPath + outFile)));
            }
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
        }

        private String[] nextLine() throws IOException {
            return in.readLine().split(" ");
        }

        private int nextSingleInt() throws IOException {
            return ivl(in.readLine());
        }

        private int[] nextLineInt() throws IOException {
            return nextLineInt(0);
        }

        private int[] nextLineInt(int offset) throws IOException {
            String[] inp = nextLine();
            int[] intInp = new int[offset + inp.length];
            for (int i = 0; i < inp.length; i++) intInp[offset + i] = ivl(inp[i]);
            return intInp;
        }

        private int[][] nextMatInt(int lineCount) throws IOException {
            return nextMatInt(lineCount, 0, 0);
        }

        private int[][] nextMatInt(int lineCount, int rowOffset, int colOffset) throws IOException {
            int[][] mat = new int[rowOffset + lineCount][];
            for (int i = rowOffset; i < mat.length; i++) mat[i] = nextLineInt(colOffset);
            return mat;
        }
    }

    private static class HpHelper {
        private static final String LOCAL_DEBUG_FLAG = "COM_PROG_DEBUG";

        private static String createDelimiter(String delimiter) {
            return delimiter == null ? " " : delimiter;
        }

        private static void println(int[] data, String delimiter) {
            delimiter = createDelimiter(delimiter);
            for (int t : data) out.print(t + delimiter);
            out.println();
        }

        private static void println(long[] data, String delimiter) {
            delimiter = createDelimiter(delimiter);
            for (long t : data) out.print(t + delimiter);
            out.println();
        }

        private static <T> void println(T[] data, String delimiter) {
            delimiter = createDelimiter(delimiter);
            for (T t : data) {
                if (t instanceof int[]) {
                    println((int[]) t, delimiter);
                } else if (t instanceof long[]) {
                    println((long[]) t, delimiter);
                } else if (t instanceof Object[]) {
                    println((Object[]) t, delimiter);
                } else {
                    out.print(t + delimiter);
                }
            }
            out.println();
        }
    }

    private static HpReader in = new HpReader();
    private static PrintWriter out;

    private static boolean isDebug() {
        try {
            return Boolean.parseBoolean(System.getenv(HpHelper.LOCAL_DEBUG_FLAG));
        } catch (Exception e) {
            return false;
        }
    }

    public static void main(String[] args) throws IOException {
        in.initAndRedirectInOut("/Users/apple/Work/WorkSpaces/CompetitiveProg/", "in.txt", null);

        String inp = in.in.readLine();
        int[] aCount = new int[inp.length() + 1];
        int[] bCount = new int[inp.length() + 1];
        for (int i = 0; i < inp.length(); i++) {
            aCount[i + 1] = aCount[i] + (inp.charAt(i) == 'a' ? 1 : 0);
            bCount[i + 1] = (i + 1) - aCount[i + 1];
        }

        int rs = 0;
        for (int i = 0; i < aCount.length; i++) {
            for (int j = i; j < aCount.length; j++) {
                rs = Math.max(rs, aCount[i] + (bCount[j] - bCount[i]) + (aCount[aCount.length - 1] - aCount[j]));
            }
        }
        out.println(rs);

        out.flush();
    }
}
