#include <bits/stdc++.h>
using namespace std;
inline long long isqrt(long long k) {
  long long r = sqrt(k) + 1;
  while (r * r > k) r--;
  return r;
}
inline long long icbrt(long long k) {
  long long r = cbrt(k) + 1;
  while (r * r * r > k) r--;
  return r;
}
inline long long mnz(long long& a, long long b) { return a = (a > b ? b : a); }
inline long long mxz(long long& a, long long b) { return a = (a < b ? b : a); }
inline string toString(long long n) {
  stringstream ss;
  ss << n;
  return ss.str();
}
double const eps = 1e-6;
long long const Base = 1e9 + 7, oo = 1e17, MAXN = 1e6;
long long A[MAXN + 5];
vector<pair<long long, long long> > compress(const vector<long long>& vec) {
  vector<pair<long long, long long> > v;
  long long cnt = 1;
  for (long long i = 1; i <= (long long)vec.size(); i++) {
    if (i == (long long)vec.size() or vec[i] != vec[i - 1]) {
      v.push_back(make_pair(vec[i - 1], cnt));
      cnt = 1;
    } else
      cnt++;
  }
  return v;
}
long long Solves() {
  long long n, m, k, cnt = 0, ans = 0, x, y, q, c, sum = 0, v, t;
  string s;
  cin >> s;
  vector<long long> vec;
  for (long long i = 0; i + 1 <= s.length(); i++) vec.push_back(s[i]);
  vector<pair<long long, long long> > vv = compress(vec);
  for (long long i = 0; i < vv.size(); i++) {
    c = vv[i].second - 1;
    x = (c / 3 * 2 + 1);
    if (c % 3 == 2) x++;
    ans += x;
  }
  for (long long i = 1; i <= (long long)vv.size() - 1; i++) {
    x = vv[i].second - 1;
    x %= 3;
    y = vv[i - 1].second - 1;
    y %= 3;
    if (x == y and x == 1) {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}
int main() {
  long long JUDGE_ONLINE = 1;
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  for (long long T = 1; T <= test; T++) {
    Solves();
  }
  if (!JUDGE_ONLINE)
    cout << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
}
