#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int count = 1, tmp = 1;
  for (int i = 0; i < s.size() - 1; i++) {
    if (s.at(i) == s.at(i + 1)) {
      tmp++;
      if (i == s.size() - 2) {
        if (tmp % 3 == 0) {
          count += (tmp / 3) * 2;
        } else {
          count += (tmp / 3) * 2 + 1;
        }
      }
    } else {
      if (tmp != 1 & tmp % 3 == 0) {
        count += (tmp / 3) * 2;
        tmp = 1;
      } else if (tmp != 1 & tmp % 3 != 0) {
        count += (tmp / 3) * 2 + 1;
        tmp = 1;
      } else {
        count++;
      }
    }
  }
  cout << count;
}
