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>
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n >> b) & 1; }
inline void set_bit(int& n, int b) { n |= two(b); }
inline void unset_bit(int& n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) {
  int res = 0;
  while (n && ++res) n -= n & (-n);
  return res;
}
long long int gcd(long long int a, long long int b) {
  return (a ? gcd(b % a, a) : b);
}
long long int modPow(long long int a, long long int b, long long int MOD) {
  long long int x = 1, y = a;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x * y) % MOD;
    }
    b /= 2;
    y = (y * y) % MOD;
  }
  return x;
}
long long int modInverse(long long int a, long long int p) {
  return modPow(a, p - 2, p);
}
using namespace std;
const int N = 5e3 + 5;
string str;
int prefa[N];
int prefb[N];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, i, j, k;
  cin >> str;
  n = str.size();
  prefa[0] = (str[0] == 'a' ? 1 : 0);
  prefb[0] = (str[0] == 'b' ? 1 : 0);
  for (i = (1); i <= (n - 1); i++) {
    prefa[i] = prefa[i - 1] + (str[i] == 'a' ? 1 : 0);
    prefb[i] = prefb[i - 1] + (str[i] == 'b' ? 1 : 0);
  }
  int ans = 0;
  for (i = 0; i < (n); i++) {
    ans = max(ans, prefb[i] + prefa[n - 1] - prefa[i]);
    for (j = (i); j <= (n - 1); j++) {
      int all_b = prefb[j] - prefb[i];
      int left_a = prefa[i];
      int right_a = prefa[n - 1] - prefa[j];
      ans = max(ans, all_b + left_a + right_a);
    }
  }
  cout << ans;
  return 0;
}