#include <bits/stdc++.h>
using namespace std;
signed main() {
  string s;
  cin >> s;
  int n = s.length();
  int ans = 0;
  for (int i = 0; i < n; i++) {
    int cnt = 0;
    for (int j = i; j < n && s[j] == s[i]; j++) {
      cnt++;
    }
    if (cnt % 3 == 0)
      ans += cnt / 3 * 2;
    else
      ans += cnt / 3 * 2 + 1;
    i += cnt - 1;
  }
  cout << ans << endl;
}
