#include <bits/stdc++.h>
using namespace std;
string s;
int main() {
  std::ios::sync_with_stdio(false);
  int n, m, mas;
  cin >> s;
  int len = s.size();
  s[len] = 'A';
  int sum = 1;
  int ans = 0;
  for (int i = 1; i <= len; i++) {
    if (s[i] == s[i - 1])
      sum++;
    else {
      if (sum == 1 || s[i] == 'A')
        ans++;
      else {
        int temp = sum / 3;
        int mod = sum % 3;
        ans += temp * 2;
        if (mod != 0) {
          ans++;
        }
        if (mod == 2) {
          ans++;
          i++;
        }
      }
      sum = 1;
    }
  }
  cout << ans << endl;
  return 0;
}
