#include <bits/stdc++.h>
using namespace std;
int fun(int l) { return 2 * (l / 3) + bool(l % 3); }
int main() {
  cin.sync_with_stdio(0);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 0;
  int prev = 0;
  for (int i = 0; i < int(s.size());) {
    int j = i + 1;
    while (j < int(s.size()) && s[i] == s[j]) ++j;
    ans += fun(j - i);
    int cur = (j - i) % 3 == 2;
    ans += prev && cur;
    prev = !prev && cur;
    i = j;
  }
  cout << ans << endl;
}
