#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 998244353;
int main() {
  string S;
  cin >> S;
  int ss = S.size(), cnt = 0, ans = 0;
  vector<int> A;
  for (int i = 1; i < ss; i++) {
    if (S[i] != S[i - 1]) {
      A.push_back(i - cnt);
      cnt = i;
    }
  }
  A.push_back(ss - cnt);
  for (int &i : A) {
    ans += i / 3 * 2;
    i %= 3;
  }
  bool j = false;
  A.push_back(0);
  ss = A.size(), cnt = 0;
  for (int i = 0; i < ss; i++) {
    if (A[i]) ans++;
    if (i == 0) continue;
    if (A[i] == 2 && A[i - 1] == 2) {
      if (A[i + 1] != 2) ans++;
    }
  }
  cout << ans << endl;
  return 0;
}
