#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int count = 0, cont = 0, precont = 0;
  char pre = s[0];
  for (int i = 1; i < s.length(); i++) {
    if (pre == s[i]) {
      ++cont;
      if (i == s.length() - 1) {
        if (cont == 1 and precont == 1) {
          count += 2;
          cont = 0;
          precont = 0;
        }
        count += 2 * cont / 3;
        if (cont % 3 != 0) ++count;
      }
    } else {
      if (cont != 0) {
        if (cont == 1 and precont == 1) {
          count += 2;
          cont = 0;
          precont = 0;
        } else {
          count += 2 * cont / 3;
          if (cont % 3 != 0) ++count;
          precont = cont;
          cont = 0;
        }
      } else {
        ++count;
        precont = 0;
      }
      if (i == s.length() - 1) ++count;
    }
    pre = s[i];
  }
  cout << count << endl;
  return 0;
}
