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;
long long modx(long long Base, long long exponent) {
  long long ans = 1;
  if (Base == 1) return Base;
  while (exponent) {
    if (exponent & 1) ans = (ans * Base) % 1000000007LL;
    Base = (Base * Base) % 1000000007LL;
    exponent = exponent >> 1;
  }
  return ans;
}
long long inmodx(long long num) { return (modx(num, 1000000007LL - 2LL)); }
bool cmp(pair<pair<int, int>, int> a, pair<pair<int, int>, int> b) {
  if (a.first.first / 900 < b.first.first / 900) return 1;
  if (a.first.first / 900 > b.first.first / 900) return 0;
  if (a.first.second <= b.first.second) return 1;
  return 0;
}
const int N = (5e3) + 9;
const int M = (N << 2) + 9;
const int LOGN = ((int)log2(N)) + 3;
const int LOGM = ((int)log2(M)) + 3;
const int BUCK = 450;
string s;
int a[N], b[N];
int calc(int x[], int l, int r) {
  if (l > r) return 0;
  return (x[r] - x[l - 1]);
}
void solve() {
  int n, i, j, ans = 0, val;
  cin >> s;
  n = s.length();
  for (i = (0); i < (n); i++) {
    a[i + 1] = a[i];
    b[i + 1] = b[i];
    if (s[i] == 'a')
      a[i + 1]++;
    else
      b[i + 1]++;
  }
  ans = max(a[n], b[n]);
  for (i = (1); i < (n + 1); i++)
    for (j = (i); j < (n + 1); j++) {
      val = calc(a, 1, i - 1) + calc(b, i, j) + calc(a, j + 1, n);
      ans = max(ans, val);
    }
  cout << ans << '\n';
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1, cs;
  cout << fixed << setprecision(9);
  for (cs = (1); cs < (t + 1); cs++) {
    solve();
  }
  return 0;
}