#include <bits/stdc++.h>
using namespace std;
static const long long MOD = 1e9 + 7;
static const long long INF = 1e25;
static const long long MAX_M = 100001;
int main() {
  string s;
  cin >> s;
  string t = s;
  reverse(t.begin(), t.end());
  long long same = 0;
  long long ans = 0;
  char x = t[0];
  while (x == t[same++])
    ;
  long long cnt = t.size() - (same - 1);
  for (int i = 1; i < cnt;) {
    if (t.size() == 1 && t[0] == s[i]) {
      ans++;
      t = s.substr(i, 2);
      i += 2;
    } else {
      ans++;
      t = s.substr(i, 1);
      i++;
    }
  }
  if (same == 1 || same == 2)
    ans++;
  else {
    ans += same - 2;
  }
  cout << ans << endl;
  return 0;
}
