#include <bits/stdc++.h>
using namespace std;
int ans = 1e6;
void go(string s) {
  ans = min(ans, (int)s.length());
  for (int i = 1; i < (int)s.length(); ++i) {
    if ((s[i] == '0' and s[i - 1] == '1') or
        (s[i] == '1' and s[i - 1] == '0')) {
      string beg = s.substr(0, i - 1);
      string en = s.substr(i + 1);
      go(beg + en);
      break;
    }
  }
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int n = (int)s.length();
  go(s);
  cout << n - ans << endl;
  return 0;
}
