#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 10;
int cnt[MAXN];
int main(void) {
  string s;
  cin >> s;
  for (int i = 0; i < s.length(); i++) {
    if (i == 0) {
      if (s[i] != s[i + 1]) cnt[i]++;
    } else if (i + 1 < s.length()) {
      if (s[i] != s[i - 1]) cnt[i]++;
      if (s[i] != s[i + 1]) cnt[i]++;
    } else {
      if (s[i - 1] != s[i]) cnt[i]++;
    }
  }
  vector<int> v;
  bool isZero = false;
  for (int i = 0; i < s.length(); i++) {
    if (cnt[i] == 0 && isZero == false) {
      v.push_back(i);
      isZero = true;
    } else if (cnt[i]) {
      isZero = false;
    }
  }
  int ans = v.size() - 1;
  char lastChar = s[0];
  for (int i = 1; i < v.size(); i++) {
    if (s[v[i]] != lastChar) ans++, lastChar = s[v[i]];
  }
  cout << ans << endl;
  return 0;
}
