#include <bits/stdc++.h>
using namespace std;
string S;
int f(int L) {
  int ans = 2 * ((L) / 3);
  if (L % 3 > 0) ans += 1;
  return ans;
}
int main() {
  cin >> S;
  int i = 0;
  vector<int> streaks;
  while (i < S.size()) {
    int j = 0;
    while (i + j + 1 < S.size() && S[i + j] == S[i + j + 1]) {
      j++;
    }
    streaks.push_back(j + 1);
    i += j + 1;
  }
  int K = 0;
  for (int i = 0; i < streaks.size(); i++) {
    if (i + 1 < streaks.size() && streaks[i] % 3 == 2 &&
        streaks[i + 1] % 3 == 2) {
      K += 1;
      streaks[i] -= 1;
      streaks[i + 1] -= 1;
    }
    K += f(streaks[i]);
    streaks[i] = 0;
  }
  cout << K << "\n";
}
