#include <bits/stdc++.h>
using namespace std;
long long N;
long long M;
string s;
int main() {
  string S;
  cin >> S;
  queue<char> que;
  long long ans = 0;
  long long i = 1;
  for (long long j = 0; j < S.length() / 3; j++) {
    if (S[i] != S[i + 1]) {
      if (S[i] != S[i - 1] && S[i + 1] != S[i + 2]) {
        ans += 1;
      }
    }
    ans += 2;
    i += 2;
  }
  if (S.length() % 3 == 1) {
    ans += 1;
  } else if (S.length() % 3 == 2) {
    if (S[S.length() - 1] == S[S.length() - 2]) {
      ans += 1;
    } else {
      ans += 2;
    }
  }
  long long ans2 = 0;
  i = 0;
  for (long long j = 0; j < S.length() / 3; j++) {
    if (S[i] != S[i + 1]) {
      if (S[i] != S[i - 1] && S[i + 1] != S[i + 2]) {
        ans2 += 1;
      }
    }
    ans2 += 2;
    i += 3;
  }
  if (S.length() % 3 == 1) {
    ans2 += 1;
  } else if (S.length() % 3 == 2) {
    if (S[S.length() - 1] == S[S.length() - 2]) {
      ans2 += 1;
    } else {
      ans2 += 2;
    }
  }
  if (ans > ans2) {
    cout << ans << endl;
  } else {
    cout << ans2 << endl;
  }
}
