#include <bits/stdc++.h>
int main() {
  char S[100000];
  int IS[100000];
  int ISS[100000];
  int N, i, j, count;
  scanf("%s", S);
  int a = sizeof(S);
  for (i = 0; i < a; i++) {
    IS[i] = S[i] - '0';
  }
  for (j = 0; j < 10000; j++) {
    for (i < 0; i < a - 1; i++) {
      if (IS[i] != 5)
        ;
      else if (IS[i] == IS[i + 1]) {
        IS[i] = IS[i + 1] = 5;
      } else
        ;
    }
    count = 0;
    for (i = 0; i < a; i++) {
      if (IS[i] != 5) ISS[count] = IS[i];
      count++;
    }
  }
  printf("%d", a - count);
  return 0;
}
