#include <bits/stdc++.h>
using namespace std;
int main(void) {
  char tmp = 0;
  char now;
  int cnt = 0;
  int n = 0;
  int ans = 0;
  bool past2 = false;
  while (cin >> now) {
    if (tmp == 0) {
      cnt++;
      tmp = now;
    } else {
      if (now == tmp) {
        cnt++;
        if (cnt == 3) {
          n++;
          cnt = 0;
        }
      } else {
        ans += n * 2;
        if (cnt != 0) {
          ans++;
        }
        if (cnt == 2 && past2) {
          ans++;
          past2 = false;
        } else if (cnt == 2) {
          past2 = true;
        } else {
          past2 = false;
        }
        tmp = now;
        cnt = 1;
        n = 0;
      }
    }
  }
  ans += n * 2;
  if (cnt != 0) {
    ans++;
  }
  if (cnt == 2 && past2) {
    ans++;
    past2 = false;
  }
  cout << ans << endl;
  return (0);
}
