#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll solve() {
  string S;
  cin >> S;
  ll n = S.size();
  ll nl = 1;
  char cl = S[n - 1];
  while (nl + 1 < n && S[n - nl - 1] == cl) nl++;
  ll ans = 1;
  bool n2 = false;
  char c = S[0];
  for (int i = 1; i < n - nl; i++) {
    if (S[i] == c) {
      n2 = true;
      i++;
    } else {
      n2 = false;
    }
    ans++;
    c = S[i];
  }
  if (n2) nl--;
  ans += nl - (nl + 1) / 3;
  return ans;
}
int main() {
  auto ans = solve();
  cout << ans << "\n";
  return 0;
}
