#include <bits/stdc++.h>
using namespace std;
int inf = 1e9;
long long p = 998244353;
int ans[300000][2];
int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(100);
  int n;
  string s;
  cin >> s;
  n = s.size();
  ans[0][0] = 1;
  ans[1][1] = 1;
  if (s[0] == s[1]) {
    ans[1][0] = 0;
  } else
    ans[0][1] = 2;
  for (int i = 2; i < n; i++) {
    if (s[i] != s[i - 1]) {
      ans[i][0] = max(ans[i][0], ans[i - 1][0] + 1);
    }
    ans[i][0] = max(ans[i][0], ans[i - 1][1] + 1);
    ans[i][1] = max(ans[i - 2][1] + 1, ans[i - 2][0] + 1);
  }
  cout << max(ans[n - 1][0], ans[n - 1][1]);
  return 0;
}
