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;
template <class T>
inline T BMOD(T p, T e, T m) {
  T ret = 1;
  while (e) {
    if (e & 1) ret = (ret * p) % m;
    p = (p * p) % m;
    e >>= 1;
  }
  return (T)ret;
}
template <class T>
inline T MODINV(T a, T m) {
  return BMOD(a, m - 2, m);
}
template <class T>
inline T isPrime(T a) {
  for (T i = 2; i <= sqrt(double(a)); i++) {
    if (a % i == 0) {
      return 0;
    }
  }
  return 1;
}
template <class T>
inline T lcm(T a, T b) {
  return (a / __gcd(a, b)) * b;
}
template <class T>
inline T power(T a, T b) {
  return (b == 0) ? 1 : a * power(a, b - 1);
}
template <class T>
inline string toString(T t) {
  stringstream ss;
  ss << t;
  return ss.str();
}
template <class T>
inline long long toLong(T t) {
  stringstream ss;
  ss << t;
  long long ret;
  ss >> ret;
  return ret;
}
template <class T>
inline int toInt(T t) {
  stringstream ss;
  ss << t;
  int ret;
  ss >> ret;
  return ret;
}
template <class T>
inline bool leapYear(T t) {
  if (!(t % (T)400) || (!(t % (T)4) && t % (T)100)) return true;
  return false;
}
string buffer;
int INT() {
  getline(cin, buffer);
  return toInt(buffer);
}
int LONG() {
  getline(cin, buffer);
  return toLong(buffer);
}
const int MX = 200010;
const long long MD = 1e9 + 7;
string s;
int sv[5005][5], l;
int go(int p, int f) {
  if (p >= l) return 0;
  int &ret = sv[p][f];
  if (ret != -1) return ret;
  ret = 0;
  if (f == 0) {
    int fl = 0;
    if (s[p] == 'a') fl = 1;
    ret = max(ret, fl + go(p + 1, f));
    ret = max(ret, fl + go(p + 1, 1));
    ret = max(ret, (!fl) + go(p + 1, 1));
  }
  if (f == 1) {
    int fl = 0;
    if (s[p] == 'b') fl = 1;
    ret = max(ret, fl + go(p + 1, f));
    ret = max(ret, fl + go(p + 1, 2));
    ret = max(ret, (!fl) + go(p + 1, 2));
  }
  if (f == 2) {
    int fl = 0;
    if (s[p] == 'a') fl = 1;
    ret = max(ret, fl + go(p + 1, f));
  }
  return ret;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  l = s.size();
  memset(sv, -1, sizeof sv);
  int Ans = go(0, 0);
  cout << Ans << endl;
  return 0;
}