#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 0, ans = 0;
  for (int i = 1; i < s.length() - 1; i++) {
    if (s[i] == '?')
      count++;
    else
      count = 0;
    ans = max(ans, count);
  }
  cout << ans << endl;
}
