#include <bits/stdc++.h>
const long long INF = 10000000000000;
const long long mod = 1e9 + 7;
using namespace std;
void add(int& a, int b) {
  a += b;
  if (a >= mod) a -= mod;
}
long long mul(long long a, long long b) { return (a * b) % mod; }
int solve(string s) {
  int n = s.length();
  if (n == 1) return cout << 1 << endl, 0;
  vector<string> v;
  int fin = n - 2;
  int nb = 1;
  while (fin >= 0 && s[fin] == s[n - 1]) {
    fin--;
    nb++;
  }
  std::vector<int> verif1;
  int tmp = nb;
  while (tmp) {
    if (!verif1.size()) {
      verif1.push_back(1);
      tmp--;
    } else if (verif1[verif1.size() - 1] == 1 && tmp >= 2) {
      verif1.push_back(2);
      tmp -= 2;
    } else {
      verif1.push_back(1);
      tmp--;
    }
  }
  int res = -1;
  if (verif1.size() == 1 ||
      verif1[verif1.size() - 1] != verif1[verif1.size() - 2])
    res = verif1.size();
  if (res == -1) {
    tmp = nb;
    verif1.clear();
    while (tmp) {
      if (!verif1.size() && tmp >= 2) {
        verif1.push_back(2);
        tmp -= 2;
      } else if (verif1[verif1.size() - 1] == 1 && tmp >= 2) {
        verif1.push_back(2);
        tmp -= 2;
      } else {
        verif1.push_back(1);
        tmp--;
      }
    }
    res = verif1.size();
  }
  for (int i = 0; i <= fin; i++) {
    string t = "";
    t += s[i];
    if (!v.size())
      v.push_back(t);
    else {
      if (v[v.size() - 1] == t && i < fin) {
        t += s[i + 1];
        i++;
        v.push_back(t);
      } else if (t != v[v.size() - 1])
        v.push_back(t);
    }
  }
  return res + v.size();
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  ;
  string s;
  cin >> s;
  int ans1 = solve(s);
  cout << ans1 << endl;
  return 0;
}
