#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int ans = 1, k = 0, l = 0, m;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s[i] == s[i + 1]) {
      k++;
    } else {
      ans += 1 + k / 2;
      m = (k % 2 == 1) ? (k / 2 - 1) % 3 : (k / 2) % 3;
      if (k == 1) m = 1;
      if (l > 0 && m > 0) {
        ans++;
        m--;
      }
      l = m;
      k = 0;
    }
  }
  ans += k / 2;
  m = (k % 2 == 1) ? (k / 2 - 1) % 3 : (k / 2) % 3;
  if (k == 1) m = 1;
  if (l > 0 && m > 0) {
    ans++;
    m--;
  }
  cout << ans << endl;
  return 0;
}
