#include <bits/stdc++.h>
using namespace std;
void solve(std::string S) {
  long long N = S.size();
  vector<long long> dp(N, 1);
  if (N >= 2) dp[1] = dp[0] + (S[0] != S[1]) ? 1 : 0;
  if (N >= 3) dp[2] = dp[1] + (S[1] != S[2]) ? 1 : 0;
  for (long long i = 3; i < N; i++) {
    if (S[i] != S[i - 1]) {
      dp[i] = dp[i - 1] + 1;
    } else {
      dp[i] = dp[i - 3] + 2;
    }
  }
  cout << *max_element(dp.begin(), dp.end()) << endl;
}
int main() {
  std::string S;
  std::cin >> S;
  solve(S);
  return 0;
}
