#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int len = s.size();
  int ans = 0;
  int carry = 0;
  for (int i = 0, j = 0; i < len; i = j) {
    while (j < len && s[i] == s[j]) j++;
    ans += ((j - i) / 3) * 2;
    int rest = (j - i) % 3;
    if (carry) {
      if (carry == 2 && rest == 2)
        ans += 3, carry = 0;
      else if (rest == 2)
        ans += 1, carry = 1;
      else if (carry == 2)
        ans += 2, carry = 0;
      else
        ans++, carry = 1;
    } else {
      carry = rest;
    }
  }
  if (carry) ans++;
  cout << ans << endl;
  return 0;
}
