#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
int func(int x) {
  if (x % 3 == 2) return x / 3 + 1;
  return x / 3;
}
const int MAX = 2e5 + 10;
int dp[MAX];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string s;
  cin >> s;
  int n = s.size();
  vi v;
  int cnt = 1;
  for (int i = 1; i < n; i++) {
    if (s[i] != s[i - 1]) {
      v.push_back(cnt);
      cnt = 1;
    } else
      cnt++;
  }
  v.push_back(cnt);
  int b = v.size();
  int res = 0;
  for (int i = 1; i < b; i++) {
    if ((v[i] % 3 == 2 || v[i - 1] % 3 == 2) && v[i - 1] > 0 && v[i] > 0) {
      v[i]--;
      v[i - 1]--;
      res++;
    }
  }
  for (int i = 0; i < b; i++) {
    res += func(v[i]);
  }
  cout << n - res << endl;
}
