#include <bits/stdc++.h>
using namespace std;
template <typename T>
void _dbg(const char* _s, T _h) {
  cerr << _s << " = " << _h << "\n";
}
template <typename T, typename... Ts>
void _dbg(const char* _s, T _h, Ts... _t) {
  int _b = 0;
  while (((_b += *_s == '(') -= *_s == ')') != 0 || *_s != ',') cerr << *_s++;
  cerr << " = " << _h << ",";
  _dbg(_s + 1, _t...);
}
const int64_t INF = static_cast<int64_t>(1e9) + 7;
const int64_t LINF = INF * INF;
const int MAXN = static_cast<int>(1e6) + 17;
void solve() {
  string second;
  cin >> second;
  int n = second.length();
  int res = 0;
  for (int i = 0; i < n - 1; ++i) {
    int cur = 1;
    while (i + 1 < n && second[i] == second[i + 1]) {
      ++i;
      ++cur;
    }
    res += 2 * (cur / 3) + (cur % 3 != 0);
    if (i + 1 < n && cur == 2) {
      ++i;
      ++res;
    }
  }
  if (n > 1) {
    res += second[n - 1] != second[n - 2];
  }
  cout << res << endl;
}
int main() {
  cin.tie(nullptr);
  cout.tie(nullptr);
  ios_base::sync_with_stdio(false);
  int q = 1;
  for (int i = 0; i < q; ++i) {
    solve();
  }
}
