#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int sum = 0;
  int i = 0;
  set<int> step;
  if (s.size() > 1) {
    if (i == 0 && s[0] != s[1]) {
      sum++;
      s[0] = s[1];
      step.insert(0);
      i++;
    }
    while (i < s.size()) {
      if (s[i] != s[i + 1]) {
        if (step.count(i)) {
        } else {
          sum++;
          s[i] = s[i - 1];
          s[i + 1] = s[i + 2];
          step.insert(i);
          i = 0;
        }
      } else if (s[i] == s[i + 1]) {
      }
      i++;
    }
  }
  int n = s.size();
  cout << min(2 * sum, n) << endl;
}
