#include <bits/stdc++.h>
using namespace std;
constexpr int INF = 1100000000;
constexpr long long LLINF = 1100000000000000000;
int main() {
  string s;
  cin >> s;
  s.push_back('#');
  vector<long long> v;
  long long cnt = 1;
  for (long long i = 0; i < s.size() - 1; i++) {
    if (s[i] == s[i + 1]) {
      cnt++;
    } else {
      v.push_back(cnt);
      cnt = 1;
    }
  }
  long long ans = 0;
  for (auto e : v) {
    if (e % 3 == 0) {
      ans += e / 3 * 2;
    } else {
      ans += e / 3 * 2 + 1;
    }
  }
  for (int i = 0; i < v.size() - 1; i++) {
    if (v[i] % 3 == 2 && v[i + 1] % 3 == 2) {
      ans++;
      v[i + 1] -= 2;
    }
  }
  cout << ans << endl;
  return 0;
}
