#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
int main() {
  string s;
  cin >> s;
  int ans = 0;
  int cnt = 1;
  int len = s.size();
  vector<int> v;
  if (len == 1) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 1; i < len; i++) {
    if (i == len - 1) {
      if (s[i] == s[i - 1]) {
        cnt++;
        v.push_back(cnt);
      } else {
        v.push_back(cnt);
        v.push_back(1);
      }
    } else {
      if (s[i] == s[i - 1])
        cnt++;
      else {
        v.push_back(cnt);
        cnt = 1;
      }
    }
  }
  int vlen = v.size();
  for (int i = 0; i < vlen; i++) {
    if (i == vlen - 1) {
      if (v[i] == 1) ans++;
      if (v[i] == 2) {
        ans++;
      }
      if (v[i] >= 3) {
        if (v[i] % 3 == 0)
          ans += 2 * (v[i] / 3);
        else
          ans += 2 * (v[i] / 3) + 1;
      }
    } else {
      if (v[i] == 1) ans++;
      if (v[i] == 2) {
        ans += 2;
        v[i + 1]--;
      }
      if (v[i] >= 3) {
        if (v[i] % 3 == 0)
          ans += 2 * (v[i] / 3);
        else
          ans += 2 * (v[i] / 3) + 1;
      }
    }
  }
  cout << ans << endl;
  return 0;
}
