#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  int l = 1;
  for (int i = n - 2; i >= 0; i--) {
    if (s[i] != s[i + 1]) break;
    l++;
  }
  if (n == 2 && s[0] == s[1]) {
    cout << 1 << endl;
    return 0;
  }
  int ans = 1;
  bool f = false;
  int i;
  for (i = 1; i < n - l; i++) {
    if (s[i] == s[i - 1] && !f) {
      i++;
      f = true;
    } else
      f = false;
    ans++;
  }
  l = n - i;
  if (l % 3 == 0)
    ans += l * 2 / 3;
  else if (l % 3 == 1)
    ans += l * 2 / 3 + 1;
  else
    ans += l * 2 / 3;
  cout << ans << endl;
}
