#include <bits/stdc++.h>
int main() {
  char S[200001];
  scanf("%s", &S);
  int i, count[2] = {0, 200001};
  for (i = 1; S[i] != 0; i++) {
    if (S[i] == S[i - 1]) {
      count[0]++;
      if (S[i + 2] != 0)
        i += 2;
      else if (S[i + 1] != 0)
        i++;
    }
  }
  if (i >= 3) {
    count[1] = 1;
    for (i = 3; S[i] != 0; i++) {
      if (S[i] == S[i - 1]) {
        count[1]++;
        if (S[i + 2] != 0)
          i += 2;
        else if (S[i + 1] != 0)
          i++;
      }
    }
  }
  if (count[0] <= count[1])
    printf("%d\n", i - count[0]);
  else
    printf("%d\n", i - count[1]);
  fflush(stdout);
  return 0;
}
