#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 777;
char s[N];
int dp[N][2];
int main() {
  scanf("%s", s);
  int len = strlen(s);
  for (int i = len, j = 0; j < len; ++j, ++i) s[i] = s[j];
  for (int i = 2 * len - 1; i >= 0; --i) {
    if (s[i] == 'b') {
      dp[i][1] = 1 + dp[i + 1][0];
    } else
      dp[i][0] = 1 + dp[i + 1][1];
  }
  int ans = 0;
  for (int i = 0; i < 2 * len; ++i) {
    ans = max(ans, min(max(dp[i][0], dp[i][1]), len));
  }
  printf("%d\n", ans);
}
