#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
signed main(void) {
  string S;
  cin >> S;
  long long N = S.size(), Ans = N;
  long long now = 1;
  for (long long i = 0; i < (N - 1); ++i) {
    if (S[i] == S[i + 1]) {
      now++;
    } else {
      Ans -= (long long)(2 * (now + 1) / 3 - 1);
      now = 1;
    }
  }
  Ans -= (long long)(2 * (now + 1) / 3 - 1);
  cout << Ans << endl;
  return 0;
}
