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