#include <bits/stdc++.h>
using namespace std;
void dout() { cerr << "\n"; }
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
  cerr << H << ' ';
  dout(T...);
}
int n;
string s;
void cleanup() { return; }
void solve() {
  cin >> s;
  n = s.size();
  if (n == 1) {
    cout << 1;
    return;
  }
  if (n == 2) {
    cout << 2 - (s[0] == s[1]);
    return;
  }
  s += '#';
  int ans1 = n;
  for (int i = 0; i < n - 2; i += 3) {
    if (s[i] == s[i + 1] || s[i + 1] == s[i + 2] || s[i + 2] == s[i + 3]) {
      ans1--;
    }
  }
  if (n % 3 == 2) {
    if (s[n - 2] == s[n - 1]) {
      ans1--;
    }
  }
  s = '#' + s;
  int ans2 = n;
  for (int i = 1; i < n; i += 3) {
    if (s[i - 1] == s[i] || s[i] == s[i + 1] || s[i + 1] == s[i + 2]) {
      ans2--;
    }
  }
  cout << max(ans1, ans2);
  return;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc = 1;
  while (tc--) {
    solve();
    cleanup();
  }
}
