#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll solve() {
  string S;
  cin >> S;
  char cp = S[0];
  int n = S.size();
  int n1 = 1, n2 = -1000000, n1u = n1;
  for (int i = 1; i < n; i++) {
    int n1t = n1, n2t = n2, n1ut = n1u;
    if (cp == S[i]) {
      n1 = n2t + 1;
      n2 = n1t;
      n1u = n1t + 1;
    } else {
      n1 = max(n1t + 1, n2t + 1);
      n2 = max(n1t, n1ut);
      n1u = n1;
    }
    cp = S[i];
  }
  return max(n1, n2);
}
int main() {
  auto ans = solve();
  cout << ans << "\n";
  return 0;
}
