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