#include <bits/stdc++.h>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;
int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::string s;
  cin >> s;
  int result = 0;
  int itr = 0;
  if (s.size() == 1) {
    result = 1;
  } else if (s.size() == 2) {
    if (s[0] == s[1]) {
      result = 1;
    } else {
      result = 2;
    }
  } else {
    while (true) {
      if (itr + 1 >= s.size()) {
        if (itr == s.size() - 1) {
          result++;
          break;
        } else {
          break;
        }
      }
      if (s[itr] != s[itr + 1]) {
        itr += 2;
        result += 2;
      } else {
        itr += 3;
        result += 2;
      }
    }
    itr = s.size() - 1;
    int tmp = 0;
    while (true) {
      if (itr - 1 < 0) {
        if (itr == 0) {
          result++;
          break;
        } else {
          break;
        }
      }
      if (s[itr] != s[itr - 1]) {
        itr -= 2;
        tmp += 2;
      } else {
        tmp += 2;
        itr -= 3;
      }
    }
    result = std::max(result, tmp);
  }
  cout << result << endl;
  return 0;
}
