#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int n, i = 0, j, count = 0;
  vector<int> v;
  cin >> s;
  n = s.length();
  for (i = 0; i < n; i++) {
    if (i == n - 1)
      v.push_back(1);
    else if (s[i] != s[i + 1])
      v.push_back(1);
    else {
      j = i;
      while (j + 1 <= n - 1 && s[j] == s[j + 1]) j++;
      v.push_back(j - i + 1);
      i = j;
    }
  }
  int l = v.size();
  for (i = 0; i < l; i++) {
    if (i == l - 1) {
      if (v[i] == 2)
        count++;
      else {
        int q = v[i] / 3;
        int r = v[i] % 3;
        if (r > 0)
          count += q * 2 + 1;
        else
          count += q * 2;
      }
    } else {
      if (v[i] == 2) {
        count += 2;
        v[i + 1]--;
      } else {
        int q = v[i] / 3;
        int r = v[i] % 3;
        if (r > 0)
          count += q * 2 + 1;
        else
          count += q * 2;
      }
    }
  }
  cout << count << endl;
  return 0;
}
