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