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