#include <bits/stdc++.h>
using namespace std;
int ans;
char lastchar;
bool laste = false;
vector<pair<char, int> > v;
string a;
int main() {
  cin >> a;
  v.push_back(make_pair('Z', 0));
  for (int i = 0; i < a.size(); i++) {
    if (i != 0 && a[i] != lastchar && laste) {
      lastchar = a[i];
      continue;
    }
    lastchar = a[i];
    if (v.size() > 1 && v.back().first != a[i]) {
      int k = v.back().second;
      v.pop_back();
      v.back().second += k + 1;
      ans = max(v.back().second, ans);
      laste = true;
    } else
      v.push_back(make_pair(a[i], 0));
  }
  cout << ans;
}
