#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  ll ans = 0;
  reverse(S.begin(), S.end());
  int len = S.size();
  int c = 1;
  for (int i = 0; i < len; ++i) {
    if (i < len - 1 && S[i] == S[i + 1]) {
      c++;
    } else {
      int a = c / 3;
      int b = c % 3;
      if (a == 0) {
        ans += 1;
      } else {
        ans += b + 2 * a;
      }
      c = 1;
    }
  }
  cout << ans;
  return 0;
}
