#include <bits/stdc++.h>
using namespace std;
char str[1000029];
char stackc[10000029];
int main() {
  scanf("%s", &str);
  int count = 1;
  int operations = 0;
  int op = 0;
  stackc[0] = str[0];
  for (int i = 0; str[i + 1] != 0; i++) {
    if (stackc[count - 1] != str[i + 1] ||
        (str[i + 2] != 0 && str[i + 1] != str[i + 2])) {
      str[i] = stackc[count - 1];
      while (str[i + 1] != 0 && (str[i] != str[i + 1] ||
                                 (str[i + 2] != 0 && str[i + 1] != str[i + 2])))
        i++;
      op++;
      if (op > operations) operations = op;
      i--;
    } else {
      stackc[count++] = str[i];
      op = 0;
    }
  }
  printf("%d\n", operations);
  return 0;
}
