#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0, cnt = 0;
  vector<int> v;
  for (int i = 0; i < s.length(); i++) {
    if (i == 0)
      cnt++;
    else if (s[i] == s[i - 1])
      cnt++;
    else
      v.push_back(cnt), cnt = 1;
  }
  v.push_back(cnt);
  for (int i = 0; i < v.size() - 1; i++) {
    ans += v[i] / 3 * 2;
    v[i] %= 3;
    if (v[i] == 2 && v[i + 1] % 3 > 0)
      ans += 2, v[i + 1]--;
    else if (v[i])
      ans++;
  }
  ans += v.back() / 3 * 2 + (v.back() % 3 > 0);
  cout << ans << '\n';
  return 0;
}
