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 CPP):

Solution:
#include <bits/stdc++.h>
using namespace std;
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
int getint(string s) {
  int x = stoi(s);
  return x;
}
string getstring(int x) {
  string lol = to_string(x);
  return lol;
}
bool ok(int x, int gg) { return (x <= gg - 1 and x >= 0); }
int X[4] = {1, 0, -1, 0};
int Y[4] = {0, 1, 0, -1};
int gcd(int a, int b) {
  if (a == 0) return b;
  return gcd(b % a, a);
}
long long int lcm(long long int a, long long int b) {
  return (a * b) / gcd(a, b);
}
long long int exponentMod(long long int A, long long int B, long long int C) {
  if (A == 0) return 0;
  if (B == 0) return 1;
  long long int y;
  if (B % 2 == 0) {
    y = exponentMod(A, B / 2, C);
    y = (y * y) % C;
  } else {
    y = A % C;
    y = (y * exponentMod(A, B - 1, C) % C) % C;
  }
  return (long long int)((y + C) % C);
}
bool ispal(string x) {
  for (int i = 0, j = x.size() - 1; i < x.size(); i++, j--) {
    if (i > j) break;
    if (x[j] != x[i]) return false;
  }
  return true;
}
string s;
int n;
const int N = 5 * 1e3;
int memo[N + 10][3];
int solve(int c, int sw) {
  int &aux = memo[c][sw];
  if (c == n) return 0;
  if (aux != -1) return aux;
  int ans = 0;
  if (!sw) {
    if (s[c] != 'a') {
      ans++;
    }
    ans = ans + min(solve(c + 1, sw), solve(c + 1, 1));
  }
  if (sw == 1) {
    if (s[c] != 'b') {
      ans++;
    }
    ans = ans + min(solve(c + 1, sw), solve(c + 1, 2));
  }
  if (sw == 2) {
    if (s[c] != 'a') {
      ans++;
    }
    ans = ans + solve(c + 1, 2);
  }
  return aux = ans;
}
int main() {
  while (cin >> s) {
    n = s.size();
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < 3; j++) memo[i][j] = -1;
    }
    int aux = solve(0, 0);
    int aux1 = solve(0, 1);
    int aux2 = solve(0, 2);
    cout << n - min(aux, min(aux1, aux2)) << endl;
  }
}