#include <bits/stdc++.h>
using namespace std;
int vx[] = {0, 0, -1, 1};
int vy[] = {1, -1, 0, 0};
int dx[] = {1, 0, -1, 1, -1, 1, 0, -1};
int dy[] = {1, 1, 1, 0, 0, -1, -1, -1};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
const long long mod = 1e9 + 7;
const int INF = INT_MAX / 2;
const int N_MAX = 100010;
int main() {
  string str;
  cin >> str;
  int cnt = 0;
  int cur = 0;
  int ans = 0;
  bool flag = false;
  int flag2 = 0;
  for (int i = 0; i < int(str.size()); i++) {
    if (str[i] == str[i + 1]) {
      if (flag)
        cnt++;
      else
        cnt += 2;
      flag = true;
    } else {
      if (flag) {
        if (cnt == 2) {
          ans++;
          flag2++;
        } else if ((cnt - 3) % 3 == 0) {
          ans += (cnt - 3) / 3 * 2 + 2;
        } else {
          ans += (cnt - 3) / 3 * 2 + 3;
        }
        cnt = 0;
        flag = false;
      } else {
        ans++;
      }
    }
  }
  cout << ans + max(0, flag2 - 2) << endl;
  return 0;
}
