#include <bits/stdc++.h>
using namespace std;
vector<string> Sk(0);
int main() {
  long long res = 0;
  string S = "";
  string Sk_temp = "";
  cin >> S;
  char prev;
  for (long long i = 0; i < (long long)S.length(); i++) {
    char temp = S[i];
    if (i == 0) {
      prev = temp;
      Sk_temp += temp;
      continue;
    }
    if (prev == temp) {
      Sk_temp += temp;
    } else {
      Sk.push_back(Sk_temp);
      prev = temp;
      Sk_temp = "";
      Sk_temp += temp;
    }
  }
  Sk.push_back(Sk_temp);
  for (long long i = 0; i < (long long)Sk.size(); i++) {
    Sk_temp = Sk[i];
    if ((long long)Sk_temp.size() % 3 == 0)
      res = res + (long long)Sk_temp.size() / 3 * 2;
    else if ((long long)Sk_temp.size() % 3 == 1)
      res = res + ((long long)Sk_temp.size() - 1) / 3 * 2 + 1;
    else if ((long long)Sk_temp.size() % 3 == 2) {
      if (i + 1 < (long long)Sk.size()) {
        if ((long long)Sk[i + 1].size() % 3 == 2) {
          res = res + ((long long)Sk_temp.size() - 2) / 3 * 2 + 1;
          res = res + ((long long)Sk[i + 1].size() - 2) / 3 * 2 + 1;
          res = res + 1;
          i = i + 1;
        } else {
          res = res + ((long long)Sk_temp.size() - 2) / 3 * 2 + 1;
        }
      } else {
        res = res + ((long long)Sk_temp.size() - 2) / 3 * 2 + 1;
      }
    }
  }
  cout << (long long)res << endl;
}
