#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
int main() {
  string S;
  cin >> S;
  int cnt = 1;
  vector<int> counter;
  for (int i = 1; i < S.size(); i++) {
    if (S[i] == S[i - 1])
      cnt++;
    else {
      counter.push_back(cnt);
      cnt = 1;
    }
  }
  if (cnt >= 1) counter.push_back(cnt);
  for (int i = 0; i < counter.size() - 1; i++) {
    if (counter[i] == 2 && counter[i + 1] == 2) {
      counter[i]++;
      i++;
    }
  }
  int ans = 0;
  for (int i = 0; i < counter.size(); i++) {
    if (counter[i] % 3 == 0)
      ans += counter[i] / 3 * 2;
    else
      ans += counter[i] / 3 + 1;
  }
  cout << ans << '\n';
}
