#include <bits/stdc++.h>
using namespace std;
struct type {
  long long k, i, j;
};
bool isPrime(long long n) {
  if (n <= 1) return false;
  if (n <= 3) return true;
  if (n % 2 == 0 || n % 3 == 0) return false;
  for (long long i = 5; i * i <= n; i = i + 6)
    if (n % i == 0 || n % (i + 2) == 0) return false;
  return true;
}
long long findSubarray(long long arr[], long long n, long long k) {
  long long window_sum = 0;
  long long min_window = INT_MAX;
  long long last = 0;
  for (long long i = 0; i < n; i++) {
    window_sum += arr[i];
    if (i + 1 >= k) {
      if (min_window > window_sum) {
        min_window = window_sum;
        last = i;
      }
      window_sum -= arr[i + 1 - k];
    }
  }
  long long sum = 0;
  for (long long i = last - k + 1; i <= last; i++) {
    sum += arr[i];
  }
  return sum;
}
long long nextpermutation(vector<long long> v) {
  vector<long long> t = v;
  sort((t).begin(), (t).end());
  long long x = 0;
  while (true) {
    x++;
    if (t == v) {
      return x;
    }
    next_permutation((t).begin(), (t).end());
  }
}
signed main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  cout << fixed << setprecision(12);
  string s;
  cin >> s;
  long long n = s.length();
  long long x = 1;
  long long ans = 0;
  for (long long i = 0; i < n - 1; i++) {
    if (s[i] != s[i + 1]) {
      ans += 2 * (x / 3);
      if (x % 3 == 1) ans++;
      if (x % 3 == 2) {
        ans += 2;
        i += 1;
        i = min(i, n - 2);
      }
      x = 1;
    } else {
      x++;
    }
  }
  x++;
  ans += 2 * (x / 3);
  if (x % 3 != 0) ans++;
  x = 0;
  cout << (ans) << "\n";
}
