#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  int temp = 0, ans = 1;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S[i] != S[i + 1])
      ans++;
    else {
      ans += 2;
      i += 2;
      if (i == S.size())
        ans -= 2;
      else if (i == S.size() - 1)
        ans--;
    }
  }
  temp = ans, ans = 2;
  for (int i = 2; i < S.size() - 1; i++) {
    if (S[i] != S[i + 1])
      ans++;
    else {
      ans += 2;
      i += 2;
      if (i == S.size())
        ans--;
      else if (i == S.size() - 1)
        ans -= 2;
    }
  }
  ans = max(temp, ans);
  cout << ans << endl;
}
