#include <bits/stdc++.h>
using namespace std;
const int inf = 2147483647, dx[] = {-1, 0, 1, 0}, dy[] = {0, -1, 0, 1};
const int N = 100005, M = 1000005, K = 200005, mod = 1000000007;
const long long llinf = 9223372036854775807ll;
string s;
int ans, t;
bool f;
char c;
int main() {
  cin >> s;
  f = false, t = 1, c = s[s.size() - 1];
  for (int i = s.size() - 2; i >= 0; i--)
    if (s[i] == c)
      t++;
    else
      break;
  for (int i = 0; i < s.size(); i++) {
    if (i == s.size() - t) {
      if (t % 3 == 0)
        ans += (t / 3 * 2);
      else
        ans += (t / 3 * 2 + 1);
      break;
    } else if (s[i] != s[i - 1] || i == 0 || f)
      ans++, f = false;
    else
      ans++, i++, f = true;
  }
  cout << ans;
  return 0;
}
