#include <bits/stdc++.h>
using namespace std;
long long test[123456];
signed main() {
  long long n = 0, sum = 1, ans = 0;
  string s;
  cin >> s;
  for (long long h = 1; h < s.size(); h++) {
    if (s[h - 1] != s[h]) {
      if (sum % 3 == 0) {
        ans += sum / 3 * 2;
      } else {
        ans += sum / 3 * 2 + 1;
      }
      sum = 0;
      n = 0;
    } else {
      sum++;
    }
  }
  if (sum % 3 == 0) {
    ans += sum / 3 * 2;
  } else {
    ans += sum / 3 * 2 + 1;
  }
  cout << ans << endl;
}
