#include <bits/stdc++.h>
using namespace std;
const double pie1 = 3.1415926;
const double pie2 = 3.14159265358979;
const double pie3 = 3.14159265358979323846;
const int vbi = 999999999;
const int vli = -vbi;
const long long vbl = 999999999999999999;
const long long vll = -vbl;
priority_queue<int> pqi;
priority_queue<long long> pql;
queue<int> qi;
queue<long long> ql;
bool pss(int a) {
  for (int i = 2; i <= sqrt(a); i++)
    if (a % i == 0) return false;
  return true;
}
int doit(int size_) {
  int ans = size_ / 3;
  ans *= 2;
  if (ans * 3 < size_) ans++;
  return ans;
}
int main() {
  ios::sync_with_stdio(false);
  string str;
  cin >> str;
  int en = str.size() - 1;
  for (int i = str.size() - 2; i >= 0; i--)
    if (str[i] == str[i + 1])
      en = i;
    else
      break;
  if (en == 0) {
    cout << doit(str.size() - en);
    return 0;
  }
  string old = "";
  int ans = 0;
  for (int i = 0; i < en; i++) {
    ans++;
    stringstream stream;
    stream << str[i];
    string sss = stream.str();
    if (sss != old) {
      old = str[i];
    } else {
      int sz = 2, j = i + 1;
      while (str.substr(i, sz) == old) {
        sz++;
        j++;
        if (i + sz - 1 >= en) en++;
      }
      old = str.substr(i, sz);
      i = j;
    }
  }
  cout << ans + doit(str.size() - en);
  return 0;
}
