#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  vector<int> lst;
  char current = S[0];
  int count = 0;
  int flag = 0;
  for (auto itr = S.begin() + 1; itr != S.end(); ++itr) {
    if (current != *itr) {
      count += 1;
      current = *itr;
      flag = 1;
    } else {
      current = *itr;
    }
  }
  int res = 0;
  if (flag == 0) {
    cout << 0 << "\n";
    return 0;
  } else if (*(S.begin()) != *(S.end() - 1)) {
    res = count * 2 + 1;
  } else {
    res = count * 2;
  }
  cout << res << "\n";
}
