#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long int n = s.length();
  vector<long int> v;
  long int cnt = 1;
  for (long int i = 1; i < n; ++i) {
    if (s[i] == s[i - 1]) {
      ++cnt;
      if (i == n - 1) v.push_back(cnt);
    } else {
      v.push_back(cnt);
      cnt = 1;
      if (i == n - 1) v.push_back(cnt);
    }
  }
  long int res = 0;
  for (long int i = 0; i < v.size(); ++i) {
    res += (v[i] / 3) * 2;
    if (v[i] % 3 != 0) ++res;
  }
  for (long int i = 1; i < v.size(); ++i) {
    if (v[i] % 3 == 2 && v[i - 1] % 3 == 2) {
      ++res;
      ++i;
    }
  }
  cout << res;
}
