#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1e9 + 7;
long long int f(string s) {
  long long int ans = 0;
  long long int n = s.size();
  for (int i = 0; i < n - 1; i++) {
    if ((s[i] == '1' && s[i + 1] == '0') || (s[i] == '0' && s[i + 1] == '1')) {
      ans++;
      i++;
    }
  }
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int T = clock();
  string s;
  cin >> s;
  long long int n = s.size();
  long long int ans = f(s);
  string t = s[n - 1] + s.substr(0, n - 1);
  ans = max(ans, f(t));
  string r = s.substr(1) + s[0];
  ans = max(ans, f(r));
  cout << ans;
  cerr << "\n\nTIME: " << (double)(clock() - T) / CLOCKS_PER_SEC << " sec\n";
  T = clock();
  return 0;
}
