#include <bits/stdc++.h>
using namespace std;
const long long MAX = 100005;
const long long mod = 1.0e9 + 7;
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long n, m, i, x, y, z;
  string s;
  cin >> s;
  n = s.length();
  vector<pair<char, long long> > v;
  v.push_back({s[0], 0});
  m = 0;
  for (i = 1; i < n; i++) {
    if (s[i] == s[i - 1])
      continue;
    else {
      v[v.size() - 1].second = i - m;
      v.push_back({s[i], i - m});
      m = i;
    }
  }
  if (m != (n - 1)) {
    v[v.size() - 1].second = n - m;
  }
  long long k = 0, d = 0;
  for (i = 0; i < v.size(); i++) {
    if (d == 1) {
      k++;
      v[i].second--;
    }
    if ((v[i].second % 3) == 0) {
      k += 2 * (v[i].second / 3);
    } else {
      k += (2 * (v[i].second / 3) + 1);
    }
    if ((v[i].second % 3) == 2) {
      d = 1;
    } else {
      d = 0;
    }
  }
  cout << k << "\n";
  return 0;
}
