#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 5;
const int M = 17 + 5;
const int W = 1000 + 5;
const int OO = 2e9;
const int mod = 1e9 + 7;
int vis[N], cnt, ans;
string second;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> second;
  for (int i = 0; i < second.size() - 1; ++i) {
    if (second[i] == second[i + 1]) {
      vis[i] = 1;
      vis[i + 1] = 1;
    }
  }
  for (int i = 0; i < second.size(); ++i) {
    if (!vis[i]) {
      ans++;
      ans += 2 * (cnt / 3) + ((cnt % 3) != 0);
      cnt = 0;
    } else
      ++cnt;
  }
  if (cnt) ans += 2 * (cnt / 3) + ((cnt % 3) != 0);
  cout << ans << '\n';
  return 0;
}
