#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  vector<long long> cnt;
  string s;
  cin >> s;
  long long n = s.size();
  long long c = 1;
  for (long long i = 1; i < n; ++i) {
    if (s[i] != s[i - 1]) {
      cnt.push_back(c);
      c = 1;
    } else
      ++c;
  }
  cnt.push_back(c);
  long long ans = 0;
  for (long long i = 0; i < cnt.size(); ++i) {
    if (cnt[i] % 3 == 2) {
      if (i + 1 < cnt.size()) {
        ans += cnt[i] / 3 + 2;
        --cnt[i + 1];
      } else
        ans += cnt[i] / 3 + 1;
    } else
      ans += 2 * (cnt[i] / 3) + (cnt[i] % 3);
  }
  cout << ans << '\n';
}
