#include <bits/stdc++.h>
using namespace std;
string s;
char ans[200007][7];
char anss[200007][7];
int main() {
  cin >> s;
  int n = s.size();
  int sta = 0;
  int cnt = 1;
  int flag = 0;
  ans[cnt][0] = s[0];
  for (int i = 1; i < n; ++i) {
    if (s[sta] == s[i] && flag == 0) {
      if (i + 1 < n) {
        cnt++;
        flag = 1;
        i++;
        ans[cnt][0] = s[i - 1];
        ans[cnt][1] = s[i];
      } else {
        if (ans[cnt - 1][1] == 0)
          ans[cnt][1] = s[i];
        else {
          if (ans[cnt][0] == ans[cnt - 1][0] && s[i] == ans[cnt - 1][1]) {
            cnt--;
            flag = 2;
          }
        }
      }
    } else if (s[sta] != s[i] && flag == 0) {
      cnt++;
      sta = i;
      ans[cnt][0] = s[i];
    } else if (flag == 1) {
      cnt++;
      sta = i;
      flag = 0;
      ans[cnt][0] = s[i];
    }
  }
  if (flag == 2) {
    sta = n - 1;
    int cntt = 1;
    flag = 0;
    anss[cntt][0] = s[n - 1];
    for (int i = n - 2; i >= 0; --i) {
      if (s[sta] == s[i] && flag == 0) {
        if (i > 0) {
          cntt++;
          flag = 1;
          i--;
          anss[cntt][0] = s[i + 1];
          anss[cntt][1] = s[i];
        } else {
          if (anss[cntt - 1][1] == 0)
            anss[cntt][1] = s[i];
          else {
            if (anss[cntt][0] == anss[cntt - 1][0] &&
                s[i] == anss[cntt - 1][1]) {
              cntt--;
            }
          }
        }
      } else if (s[sta] != s[i] && flag == 0) {
        cntt++;
        sta = i;
        anss[cntt][0] = s[i];
      } else if (flag == 1) {
        cntt++;
        sta = i;
        flag = 0;
        anss[cntt][0] = s[i];
      }
    }
    cnt = max(cnt, cntt);
  }
  cout << cnt;
  return 0;
}
