#include <bits/stdc++.h>
using namespace std;
const int maxn = 1e6;
char a[maxn + 100];
int po[maxn + 100];
int num[maxn + 100];
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    char c = s[i];
    if (num[1] == 0) {
      a[1] = c;
      po[1] = 2;
      po[2] = 2;
      num[1]++;
      continue;
    } else if (c == a[1]) {
      if (i == s.size() - 1) {
        a[po[1]] = c;
        num[po[1]]++;
        po[1]++;
        po[2]++;
        continue;
      } else if (s[i + 1] == c or num[1] == 1) {
        a[po[1]] = c;
        num[po[1]]++;
        po[1]++;
        po[2]++;
        continue;
      } else {
        a[1] = c;
        num[1]++;
        continue;
      }
    }
    a[1] = c;
    num[1]++;
    if (a[1] == a[2])
      po[1] = po[2];
    else
      po[1] = 2;
  }
  int cnt = 0;
  for (int i = 1; i <= maxn; i++)
    if (num[i] > 1) cnt++;
  cout << cnt;
  return 0;
}
