#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int dp[200010][3];
int main() {
  string s;
  cin >> s;
  for (int i = 0; i < (int)(20010); i++)
    for (int j = 0; j < (int)(3); j++) dp[i][j] = 0;
  dp[0][1] = 0;
  dp[0][2] = 0;
  for (int i = 0; i < (int)(s.size()); i++) {
    if (s[i] != s[i + 1]) {
      chmax(dp[i + 1][1], dp[i][1] + 1);
    }
    chmax(dp[i + 2][2], dp[i][2] + 1);
    if (i == 0) continue;
    chmax(dp[i + 1][1], dp[i][2] + 1);
    if (s[i + 2] != s[i] || s[i + 1] != s[i - 1]) {
      chmax(dp[i + 1][2], dp[i][2] + 1);
    }
  }
  cout << max(dp[s.size()][1], dp[s.size()][2]) - 1 << endl;
}
