#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 7;
const int maxn = 1e6 + 5;
int n, ans;
char s[maxn];
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = (0); i < (n); ++i) s[i] -= '0';
  for (int i = (0); i < (2); ++i) {
    bool f = true;
    for (int j = (0); j < (n); ++j) {
      f &= (s[j] && (j & 1) == i) || (!s[j] && (j & 1) != i) ||
           (s[j] == '?' - '0');
    }
    if (f) {
      puts("1");
      return 0;
    }
  }
  int cnt = 0;
  for (int i = (0); i < (n); ++i) {
    if (i && s[i] != s[i - 1] || s[i] == '?' - '0') cnt = 0;
    ++cnt;
    ans = max(ans, cnt);
  }
  ans = max(2, ans);
  printf("%d\n", ans);
  return 0;
}
