#include <bits/stdc++.h>
using namespace std;
const long long maxn = 2000 * 101;
const long long INF = 1e18;
long long n, ans = 0;
deque<long long> v;
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string s1;
  cin >> s1;
  long long x = 1;
  for (int i = 1; i < s1.size(); i++) {
    if (s1[i] == s1[i - 1])
      x++;
    else {
      v.push_back(x);
      x = 1;
    }
  }
  v.push_back(x);
  n = v.size();
  for (int i = 1; i < n; i++) {
    if (v[i] % 3 == 2 && v[i - 1] % 3 == 2) {
      ans++;
      v[i]--;
      v[i - 1]--;
    }
  }
  for (int i = 0; i < n; i++) {
    ans += (v[i] / 3) * 2 + (v[i] % 3 != 0);
  }
  cout << ans;
  return 0;
}
