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;
void READ(vector<long long> &v, long long n) {
  long long a;
  for (long long i = 0; i < n; i = i + 1) {
    cin >> a;
    v.push_back(a);
  }
}
void PRINT(vector<long long> &v, long long a = 0) {
  for (long long i = a; i < v.size(); i = i + 1) {
    cout << v[i] << " ";
  }
  cout << "\n";
}
double logy(long long n, long long b) {
  if (b == 0) {
    return (-1);
  }
  if (n == 1) {
    return (0);
  }
  return ((double)log10(n) / log10(b));
}
long long power(long long k, long long n, long long m = 1000000007) {
  long long res = 1;
  while (n) {
    if (n % 2 != 0) {
      res = (res * k) % m;
    }
    k = (k * k) % m;
    n = n / 2;
  }
  return (res);
}
double power(double k, long long n) {
  double res = 1;
  while (n) {
    if (n % 2 != 0) {
      res = (res * k);
    }
    k = (k * k);
    n = n / 2;
  }
  return (res);
}
double distance(pair<long long, long long> a, pair<long long, long long> b) {
  return ((double)(sqrt((a.first - b.first) * (a.first - b.first) +
                        (a.second - b.second) * (a.second - b.second))));
}
const long long dx[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const long long dy[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
vector<pair<long long, long long> > dr;
void call() {
  dr.push_back(make_pair(1, 0));
  dr.push_back(make_pair(-1, 0));
  dr.push_back(make_pair(0, 1));
  dr.push_back(make_pair(0, -1));
}
long long n, m, k, h;
bool ok = false;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  std::cout.unsetf(std::ios::floatfield);
  std::cout.precision((long long)10);
  long long a, b, c, d, i, j, t, x, y, z;
  long long p, q, r, u, w;
  char ch, chr;
  string str, st, str1, str2, str3, str4;
  cin >> str;
  n = (long long)(str).size();
  a = count((str).begin(), (str).end(), 'a');
  b = count((str).begin(), (str).end(), 'b');
  if (a == n || b == n) {
    cout << n;
    exit(0);
  }
  vector<long long> v(n, 0), v1(n, 0);
  a = 0;
  b = 0;
  for (i = 0; i < n; i++) {
    if (str[i] == 'a') {
      a++;
      v[i] = a;
      v1[i] = b;
      continue;
    }
    j = i;
    while (j < n && str[j] == str[i]) {
      b++;
      v[j] = a;
      v1[j] = b;
      j++;
    }
    i = j - 1;
  }
  x = -1e18;
  for (i = 0; i < n; i++) {
    a = 0;
    b = 0;
    if (i) {
      a = v[i - 1];
      b = v1[i - 1];
    }
    for (j = n - 1; j >= i; j--) {
      c = v[n - 1] - v[j];
      y = v1[j] - b;
      x = max(a + c + y, x);
    }
  }
  cout << x;
}