#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 1;
  int ans = s.length();
  for (int i = 0; i < s.length() - 1; i++) {
    if (s[i] == s[i + 1]) {
      count++;
    } else if (s[i] != s[i + 1] && count != 1) {
      ans = ans - ((count - 2) / 3 + 1);
      count = 1;
    } else
      count = 1;
  }
  cout << ans;
  return 0;
}
