#include <bits/stdc++.h>
template <typename T1, typename T2>
inline void chmin(T1 &a, T2 b) {
  if (a > b) a = b;
}
template <typename T1, typename T2>
inline void chmax(T1 &a, T2 b) {
  if (a < b) a = b;
}
using long long int = long long int;
using ull = long long unsigned int;
using namespace std;
class Solve {
 public:
  int func(string S) {
    vector<string> vs;
    int idx = 0;
    for (; idx < S.size();) {
      if (idx == 0) {
        string tmp = S.substr(idx, 1);
        vs.push_back(tmp);
        idx++;
      } else {
        string tmp = S.substr(idx, 1);
        if (tmp == vs.back() && idx + 2 < S.size()) {
          tmp = S.substr(idx, 2);
          vs.push_back(tmp);
          idx += 2;
        } else {
          vs.push_back(tmp);
          idx++;
        }
      }
    }
    if (vs.size() > 2 && vs[vs.size() - 1] == vs[vs.size() - 2]) {
      return vs.size() - 1;
    }
    return vs.size();
  }
  void solve() {
    string S;
    cin >> S;
    int val1 = func(S);
    reverse(begin(S), end(S));
    int val2 = func(S);
    int ans = max(val1, val2);
    cout << ans << endl;
  }
};
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  Solve().solve();
  return 0;
}
