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.
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000 * 1000 * 1000 + 7;
const long long INF = 1ll * 1000 * 1000 * 1000 * 1000 * 1000 * 1000 + 7;
const long long MOD2 = 998244353;
const long long N = 1000 * 1000 + 10;
const long long N2 = 70;
const long double PI = 3.141592653589793;
long long gcd(long long a, long long b) {
  if (!b) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y, long long p = LLONG_MAX) {
  long long res = 1;
  x %= p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
long long lcm(long long a, long long b) { return (a * b) / gcd(a, b); }
void solve() {}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s;
  cin >> s;
  long long n = s.length();
  if (n <= 2) {
    cout << n;
    return 0;
  }
  long long ta = 0, tb = 0;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'a') {
      ta++;
    } else {
      tb++;
    }
  }
  long long dp[n];
  if (s[0] == 'a')
    dp[0] = 1;
  else
    dp[0] = 0;
  for (long long i = 1; i < n; i++) {
    if (s[i] == 'a')
      dp[i] = dp[i - 1] + 1;
    else
      dp[i] = dp[i - 1];
  }
  long long dp2[n];
  if (s[0] == 'b')
    dp2[0] = 1;
  else
    dp2[0] = 0;
  for (long long i = 1; i < n; i++) {
    if (s[i] == 'b')
      dp2[i] = dp2[i - 1] + 1;
    else
      dp2[i] = dp2[i - 1];
  }
  long long dp3[n];
  if (s[n - 1] == 'a')
    dp3[n - 1] = 1;
  else
    dp3[n - 1] = 0;
  for (long long i = (n - 2); i >= 0; i--) {
    if (s[i] == 'a')
      dp3[i] = dp3[i + 1] + 1;
    else
      dp3[i] = dp3[i + 1];
  }
  long long res = max(ta, tb);
  for (long long i = 0; i < n; i++) {
    for (long long j = i; j < n; j++) {
      long long ans = 0;
      if (i >= 1) {
        ans += dp[i - 1];
      }
      ans += dp2[j];
      if (i >= 1) {
        ans -= dp2[i - 1];
      }
      if (j < (n - 1)) ans += dp3[j + 1];
      res = max(res, ans);
    }
  }
  cout << res;
  return 0;
}
