#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  vector<int> num;
  int now = '.';
  int tmp = 0;
  for (int i = 0; i < s.size(); i++) {
    if (now != s[i]) {
      num.push_back(tmp);
      now = s[i];
      tmp = 1;
    } else
      tmp++;
  }
  num.push_back(tmp);
  bool flag = false;
  int ans = 0;
  for (int i = 0; i < num.size(); i++) {
    if (num[i] == 0) continue;
    if (num[i] % 3 == 0) {
      ans += 2 * (num[i] / 3);
      flag = false;
    } else if (num[i] % 3 == 1) {
      ans += 2 * (num[i] / 3) + 1;
      flag = false;
    } else {
      if (flag)
        ans += 2 * (num[i] / 3) + 2, flag = false;
      else
        ans += 2 * (num[i] / 3) + 1, flag = true;
    }
  }
  cout << ans << endl;
}
