#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  if (s.size() % 3 != 2) {
    long long K = 1;
    long long tmp = 0;
    for (long long i = 1; i < s.size(); i++) {
      if (s[i] == s[i - 1]) {
        K++;
        i++;
        if (i + 1 == s.size()) K--;
      } else {
        K++;
      }
    }
    cout << K << endl;
  } else {
    long long K = 0;
    long long tmp = 1;
    for (long long i = 1; i < s.size(); i++) {
      if (s[i] == s[i - 1]) {
        tmp++;
      } else {
        if (tmp == 1) {
          K++;
        } else {
          K += tmp - 1 - (tmp - 1) / 3;
          tmp = 1;
        }
      }
    }
    if (tmp == 1) {
      K++;
    } else {
      K += tmp - 1 - (tmp - 1) / 3;
      tmp = 1;
    }
    cout << K << endl;
  }
}
