#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vbl = vector<bool>;
using vint = vector<int>;
using vvll = vector<vll>;
using vstr = vector<string>;
static inline void ignore_ret(int x) { x++; }
template <class T>
inline void print(vector<T> v) {
  cout << "[ ";
  for (auto x : v) cout << x << ' ';
  cout << "]\n";
}
template <class T>
inline bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline map<T, T> factorize(T n) {
  map<T, T> r;
  for (T i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      r[i]++;
      n /= i;
    }
  }
  if (n != 1) r[n] = 1;
  return r;
}
template <class T>
inline T factorial(T n) {
  if (n == 0) return 1;
  T r = 1;
  for (T i = 2; i <= n; i++) r *= i;
  return r;
}
template <class T>
inline T nCr(T n, T k) {
  if (n < k || n < 0 || k < 0) return 0;
  T r = 1;
  k = min(k, n - k);
  for (T i = n - k + 1; i <= n; i++) r *= i;
  return r / factorial(k);
}
template <class T>
inline T min(vector<T> v) {
  return *min_element((v).begin(), (v).end());
}
template <class T>
inline T max(vector<T> v) {
  return *max_element((v).begin(), (v).end());
}
template <class T>
inline ll sum(vector<T> v) {
  return reduce((v).begin(), (v).end(), 0LL);
}
template <class T>
inline T gcd(vector<T> v) {
  T r = v[0];
  for (T i = 1; i < v.size(); i++) r = gcd(r, v[i]);
  return r;
}
template <class T>
inline T lcm(vector<T> v) {
  T r = v[0];
  for (T i = 1; i < v.size(); i++) r = lcm(r, v[i]);
  return r;
}
template <class T>
inline T dot_product(vector<T> u, vector<T> v) {
  if (u.size() < v.size()) return 0;
  T r = 0;
  for (T i = 0; i < u.size(); i++) r += u[i] * v[i];
  return r;
}
void solve(string S) {
  ll n = (ll)S.size() - 1;
  ll dp[n][2];
  vbl adjacent(n, 0);
  for (ll i = 0, i_len = (n); i < i_len; i++) {
    adjacent[i] = (S[i] == S[i + 1]);
  }
  dp[0][0] = 0;
  dp[0][1] = 2;
  dp[0][2] = 1;
  for (ll i = (1), i_len = (n - 1); i <= i_len; i++) {
    if (adjacent[i - 1]) {
      dp[i][0] = dp[i - 1][2] + 1;
      dp[i][1] = dp[i - 1][0];
      dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]);
    } else {
      dp[i][0] = dp[i - 1][2] + 1;
      dp[i][1] = max(dp[i - 1][0], dp[i - 1][1]) + 1;
      dp[i][2] = max(dp[i - 1][0], dp[i - 1][1]);
    }
  }
  cout << max(dp[n - 1][0], dp[n - 1][2] + 1) << endl;
}
int main() {
  string S;
  cin >> S;
  solve(S);
  return 0;
}
