#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  s += 'A';
  int ans = 0, cnt = 1;
  vector<int> a;
  for (int i = 0; i < n; ++i) {
    if (s[i] != s[i + 1]) {
      a.push_back(cnt);
      cnt = 1;
    } else
      cnt++;
  }
  int m = a.size();
  for (int i = 0; i < m; ++i) {
    if (a[i] % 3 == 0)
      ans += a[i] / 3 * 2;
    else if (a[i] % 3 == 1)
      ans += a[i] / 3 * 2 + 1;
    else {
      ans += a[i] / 3 * 2;
      a[i] = 2;
    }
  }
  for (int i = 0; i < m - 1; ++i) {
    if (a[i] == 2 && a[i + 1] == 2) {
      ans += 3;
      a[i] = a[i + 1] = 0;
    }
  }
  for (int i = 0; i < m; ++i)
    if (a[i] == 2) ans++;
  cout << ans << endl;
  return 0;
}
