#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9 + 7;
constexpr lint mod2 = 998244353;
int main() {
  int a = 0, tmp = 1;
  string s;
  cin >> s;
  v1i v;
  for (int i = 0; i < s.size() - 1; ++i) {
    if (s[i] != s[i + 1]) {
      v.push_back(tmp);
      tmp = 1;
    } else
      ++tmp;
  }
  v.push_back(tmp);
  bool b = 0;
  for (int i = 0; i < v.size(); ++i) {
    a += v[i] / 3 * 2;
    if (v[i] % 3 != 0) ++a;
    if (b && v[i] % 3 == 2) {
      ++a;
      b = 0;
    } else if (v[i] % 3 == 2)
      b = 1;
    else
      b = 0;
  }
  cout << a << endl;
  return 0;
}
