#include <bits/stdc++.h>
using namespace std;
char str[2000050];
int len, ans, nowlen = 1, last, book[2000050], flag;
int main() {
  gets(str + 1);
  len = strlen(str + 1);
  str[0] = ':';
  last = len;
  while (str[last] == str[last - 1]) last--;
  last--;
  for (int i = 1; i <= last; i++) {
    if (str[i] != str[i - 1]) {
      ans++;
      nowlen = 2;
      book[i] = 1;
      flag = i;
      continue;
    }
    if (str[i] == str[i - 1] && book[i - 1] > 1) {
      ans++;
      nowlen = 2;
      book[i] = 1;
      flag = i;
      continue;
    }
    if (str[i] == str[i - 1]) {
      if (nowlen == 1) {
        ans++;
        nowlen = 2;
        book[i] = 1;
        flag = i;
        continue;
      }
      if (nowlen == 2) {
        ans++;
        nowlen = 1;
        book[i] = book[i + 1] = 2;
        i++;
        flag = i;
        continue;
      }
    }
  }
  int rem = len - flag;
  if (rem % 3 == 0)
    ans += rem / 3 * 2;
  else
    ans += rem / 3 * 2 + 1;
  printf("%d", ans);
  return 0;
}
