#include <bits/stdc++.h>
using namespace std;
vector<int> nums;
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0);
  string s;
  cin >> s;
  int c = 1;
  for (int i = 1; s[i]; i++) {
    if (s[i] == s[i - 1])
      c++;
    else {
      nums.push_back(c);
      c = 1;
    }
  }
  nums.push_back(c);
  long long ans = 0;
  for (int i = 0; i < nums.size(); i++) {
    if (i != nums.size() - 1 && nums[i] == 2 && nums[i + 1] == 2) {
      ans += 3;
      i++;
    } else {
      ans += 2LL * (nums[i] / 3) + ((nums[i] % 3) > 0);
    }
  }
  cout << ans;
  return 0;
}
