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;
const int block_size = 320;
const long long mod = 1e9 + 7;
const long long inf = 1e9 + 7;
const long double eps = 1e-9;
const double PI = atan(1) * 4;
template <typename T>
inline int sign(const T &a) {
  if (a < 0) return -1;
  if (a > 0) return 1;
  return 0;
}
template <typename T>
inline void in(T &x) {
  x = 0;
  T f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  x *= f;
}
long long twop(int x) { return 1LL << x; }
template <typename A, typename B>
inline void in(A &x, B &y) {
  in(x);
  in(y);
}
template <typename A, typename B, typename C>
inline void in(A &x, B &y, C &z) {
  in(x);
  in(y);
  in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
  in(x);
  in(y);
  in(z);
  in(d);
}
template <class T>
void upd(T &a, T b) {
  a = max(a, b);
}
string s;
long long dp[100010][3];
int main() {
  memset(dp, 0x3f, sizeof(dp));
  cin >> s;
  if (s[0] == 'a') {
    dp[0][0] = 0;
    dp[0][1] = 0;
    dp[0][2] = 0;
  } else {
    dp[0][0] = 1;
    dp[0][1] = 0;
    dp[0][2] = 0;
  }
  for (long long i = 1; i < ((int)s.size()); i++) {
    if (s[i] == 'a') {
      dp[i][0] = min(dp[i - 1][0], i);
      dp[i][1] = min({dp[i - 1][0], i, dp[i - 1][1] + 1});
      dp[i][2] = min({dp[i - 1][0], i, dp[i - 1][1], dp[i - 1][2]});
    } else {
      dp[i][0] = min(dp[i - 1][0] + 1, i + 1);
      dp[i][1] = min({dp[i - 1][0], i + 1, dp[i - 1][1]});
      dp[i][2] = min({dp[i - 1][1], i + 1, dp[i - 1][0], dp[i - 1][2] + 1});
    }
  }
  long long ans = inf;
  for (long long i = 0; i < ((int)s.size()); i++) {
    for (long long j = 0; j < 3; j++) {
      ans = min(ans, dp[i][j] + ((int)s.size()) - 1 - i);
    }
  }
  cout << ((int)s.size()) - ans << endl;
  return 0;
}