#include <bits/stdc++.h>
using namespace std;
int dp[200005][2];
string ss;
int main() {
  cin >> ss;
  int Len = ss.length();
  dp[0][0] = 1;
  if (ss[0] != ss[1])
    dp[1][0] = 2;
  else
    dp[1][1] = 1;
  if (ss[0] != ss[1] && ss[1] != ss[2])
    dp[2][0] = 3;
  else
    dp[2][1] = 2;
  for (int i = 3; i < Len; i++) {
    if (ss[i] != ss[i - 1] && ss[i - 1] != ss[i - 2])
      dp[i][0] = max(max(dp[i - 2][0] + 2, dp[i - 2][1] + 2), dp[i][0]);
    dp[i][1] = max(dp[i - 3][0] + 2, max(dp[i - 3][1] + 2, dp[i][1]));
  }
  cout << max(dp[Len - 1][0], dp[Len - 1][1]);
  return 0;
}
