#include <bits/stdc++.h>
using namespace std;
string s;
vector<int> lengthList;
long lengthSum = 0;
int ans = 0;
bool isValid() {
  int headIndex = 0;
  for (int i = 1; i < lengthList.size(); i++) {
    if (lengthList[i - 1] != lengthList[i]) {
      headIndex += lengthList[i - 1];
    } else {
      if (lengthList[i] == 1) {
        if (s[headIndex] == s[headIndex + 1]) {
          return false;
        } else {
          headIndex += lengthList[i - 1];
        }
      } else {
        if (s[headIndex] == s[headIndex + 2]) {
          if (s[headIndex + 1] == s[headIndex + 3]) {
            return false;
          }
        } else {
          headIndex += lengthList[i - 1];
        }
      }
    }
  }
  return true;
}
void dfs(int len) {
  lengthList.push_back(len);
  lengthSum += len;
  if (lengthSum == s.length()) {
    if (isValid()) {
      ans = max(ans, (int)lengthList.size());
    }
  } else if (lengthSum > s.length()) {
  } else {
    if (lengthList.size() > 1) {
      if (lengthList[lengthList.size() - 2] == lengthList.back()) {
        if (lengthList.back() == 1) {
          if (s[lengthSum - 1] == s[lengthSum - 2]) {
            return;
          }
        } else {
          if (s[lengthSum - 1] == s[lengthSum - 3]) {
            if (s[lengthSum - 2] == s[lengthSum - 4]) {
              return;
            }
          }
        }
      }
    }
    dfs(1);
    lengthList.pop_back();
    lengthSum -= 1;
    if (len == 1) {
      dfs(2);
      lengthList.pop_back();
      lengthSum -= 2;
    }
  }
  return;
}
int main() {
  cin >> s;
  dfs(1);
  lengthList.pop_back();
  lengthSum -= 1;
  dfs(2);
  lengthList.pop_back();
  lengthSum -= 2;
  cout << ans << endl;
  return 0;
}
