#include <bits/stdc++.h>
using namespace std;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);
uniform_int_distribution<> DD(0, (1ll << 31));
long long random2() {
  return (long long(DD(eng)) * (1ll << 31) + long long(DD(eng))) &
         ((1ll << 62ll) - 1);
}
long long n, m, T, k, q;
const long long big = 1000000007;
const long long big2 = 1000000009;
const long long mod = 998244353;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  long long a, b, c, d;
  string s;
  cin >> s;
  char prev = '1';
  n = s.length();
  vector<long long> A;
  long long ans = 0;
  a = 0;
  for (long long c1 = 0; c1 < (n); ++c1) {
    if (s[c1] != prev) {
      if (a > 0) A.push_back(a);
      a = 0;
    }
    a++;
    prev = s[c1];
  }
  A.push_back(a);
  for (long long c1 = 0; c1 < ((int)(A).size() - 1); ++c1) {
    if (A[c1] > 1 && A[c1 + 1] > 1) {
      A[c1]--;
      A[c1 + 1]--;
      ans++;
    }
  }
  for (long long c1 = 0; c1 < ((int)(A).size()); ++c1) {
    ans += (A[c1] + 1) / 3;
  }
  cout << n - ans << "\n";
  return 0;
}
