#include <bits/stdc++.h>
using namespace std;
int foo(int n) { return (2 * n + 1) / 3; }
int main() {
  int ans = 1;
  string s;
  cin >> s;
  int i = 0;
  int n = 1;
  int m = s.size();
  while (i != m - 2) {
    if (s.at(i) == s.at(i + 1)) {
      n++;
    }
    if (s.at(i) != s.at(i + 1)) {
      ans += foo(n);
      n = 1;
    }
    i++;
  }
  if (s.at(m - 2) == s.at(m - 1)) {
    ans++;
  }
  cout << ans << endl;
}
