#include <bits/stdc++.h>
using namespace std;
const long long MOD_CONST = 1000000007;
const long long BIG_NUM = 1000000000000000000;
const int BIG_INT = 1000000000;
int main() {
  string s;
  cin >> s;
  int len = s.length();
  vector<int> dp(len + 1);
  if (len == 1) {
    cout << 1 << endl;
  } else if (len == 2) {
    cout << (s[0] == s[1] ? 1 : 2) << endl;
  } else {
    dp[0] = 1;
    dp[1] = (s[0] == s[1] ? 1 : 2);
    dp[2] = (s[0] != s[1] && s[1] != s[2] ? 3 : 2);
    for (int i = 3; i < len; i++) {
      if (s[i] == s[i - 1]) {
        dp[i] = max(dp[i], dp[i - 3] + 2);
      } else {
        dp[i] = max(dp[i], dp[i] + 1);
      }
    }
    cout << dp[len - 1] << endl;
  }
}
