#include <bits/stdc++.h>
using namespace std;
const int N = 100000;
int n;
char s[N + 5];
int main() {
  scanf("%s", s);
  n = strlen(s);
  vector<int> a;
  int j = 0;
  for (int i = 0; i < n; ++i) {
    if (i && s[i] != s[i - 1])
      a.push_back(j), j = 1;
    else
      ++j;
  }
  a.push_back(j);
  int ans = 0;
  while (!a.empty()) {
    int x = a.back();
    a.pop_back();
    if (x % 3 == 0) ans += x / 3 * 2;
    if (x % 3 == 1) ans += x / 3 * 2 + 1;
    if (x % 3 == 2) {
      if (!a.empty())
        a.back()--, ans += x / 3 * 2 + 2;
      else
        ans += x / 3 * 2 + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
