#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long nmax = 1000003;
vector<long long> v;
long long ans;
long long f(long long first) { return (first / 3) * 2 + (first % 3 > 0); }
int32_t main() {
  string s;
  cin >> s;
  for (long long i = 0; i < s.size(); i++) {
    long long cur = 1;
    while (i + 1 < s.size() && s[i + 1] == s[i]) cur++, i++;
    ans += 2 * (cur / 3);
    v.push_back(cur % 3);
  }
  long long first = ans;
  for (long long i = 0; i < v.size(); i++) {
    ans += (v[i] % 3 > 0);
    if (i + 1 < v.size() && v[i] == v[i + 1] && v[i] == 2) ans += 2, i++;
  }
  cout << ans;
}
