#include <bits/stdc++.h>
using namespace std;
void read(int &x) {
  x = 0;
  int f = 1;
  char ch = getchar();
  for (; !isdigit(ch); ch = getchar())
    if (ch == '-') f = -f;
  for (; isdigit(ch); ch = getchar()) x = x * 10 + ch - '0';
  x *= f;
}
void print(int x) {
  if (x < 0) putchar('-'), x = -x;
  if (!x) return;
  print(x / 10), putchar(x % 10 + 48);
}
void write(int x) {
  if (!x)
    putchar('0');
  else
    print(x);
  putchar('\n');
}
const int maxn = 1e6 + 10;
const int inf = 1e9;
const double eps = 1e-8;
const int mod = 1e9 + 7;
char s[maxn];
int f[maxn][3];
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  for (int i = 1; i <= n; i++) {
    if (s[i] == s[i - 1])
      f[i][1] = f[i - 1][2] + 1;
    else
      f[i][1] = f[i - 1][1] + 1;
    f[i][2] = f[i - 2][1] + 1;
    if (s[i] != s[i - 2] || s[i - 1] != s[i - 3])
      f[i][2] = max(f[i][2], f[i - 2][2] + 1);
  }
  write(max(f[n][1], f[n][2]));
  return 0;
}
