#include <bits/stdc++.h>
using namespace std;
int dp[1 << 20][2];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  if (s.size() == 1) cout << 1 << '\n', exit(0);
  int n = s.size();
  dp[1][0] = 1, dp[1][1] = -1e9;
  dp[2][0] = s[0] == s[1] ? -1e9 : 2;
  dp[2][1] = 1;
  for (int i = 2; i < n; ++i) {
    dp[i + 1][0] = (s[i] == s[i - 1] ? dp[i][1] + 1 : dp[i][0] + 1);
    dp[i + 1][1] = max(dp[i - 1][0], dp[i - 1][1]) + 1;
  }
  cout << max(dp[n][0], dp[n][1]) << '\n';
}
