#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.size(), attr = s.size() - 1, ans = s.size() / 3 * 2;
  if (len % 3 == 2) {
    ans += 2;
    if (s[len - 1] == s[len - 2]) ans--;
    attr -= 2;
  }
  if (len % 3 == 1) attr--, ans++;
  while (attr > 0) {
    if (attr == len - 1) {
      if (s[attr] != s[attr - 1] && s[attr - 1] != s[attr - 2]) ans++;
    } else if (attr == 1) {
      if (s[attr] != s[attr - 1] && s[attr] != s[attr + 1]) ans++;
    } else {
      if (s[attr] != s[attr - 1] && s[attr] != s[attr + 1] &&
          s[attr - 1] != s[attr - 2])
        ans++;
    }
    attr -= 3;
  }
  cout << ans << endl;
}
