#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T>
void chmin(T &a, T b) {
  a = min(a, b);
}
template <typename T>
void chmax(T &a, T b) {
  a = max(a, b);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  s += "1";
  int n = s.size();
  int c = 1, ans = 0;
  vector<int> v;
  for (int i = 1; i < n; i++) {
    if (i == n - 1 || (s[i] != s[i - 1] && s[i] != s[i + 1])) {
      ans += (c / 3) * 2;
      if (c % 3 != 0) ans++;
      c = 1;
    } else {
      c++;
    }
  }
  cout << ans << endl;
}
