#include <bits/stdc++.h>
using namespace std;
int Licz(string a, int nr) {
  int n = a.size();
  int il = 1, akt = nr;
  int il0 = 0, il1 = 0;
  for (;;) {
    for (;;) {
      if (a[akt] == '0')
        ++il0;
      else
        ++il1;
      akt = (akt + 1) % n;
      if (akt == nr) {
        if (il0 > 0 && il1 > 0)
          return il;
        else
          return il - 1;
      }
      if (il0 > 0 && il1 > 0) break;
    }
    ++il;
    il0 = 0;
    il1 = 0;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  string a;
  cin >> a;
  int n = a.size();
  if (a[0] == a[n - 1]) {
    int ost = n - 1;
    while (a[0] == a[ost]) --ost;
    ++ost;
    string t(n - ost, a[0]);
    for (int i = 0; i < ost; ++i) t += a[i];
    a = t;
    n = a.size();
  }
  string t = "";
  vector<int> kon;
  for (int l = 0; l < n;) {
    int p = l;
    while (p < n && a[l] == a[p]) ++p;
    --p;
    t += a[l];
    if (l != p) t += a[l];
    kon.push_back(t.size() - 1);
    l = p + 1;
  }
  a = t;
  n = a.size();
  int ogr;
  if (kon.size() == 2)
    ogr = n - 1;
  else
    ogr = kon[2];
  int odp = 0;
  for (int i = 0; i <= ogr; ++i) odp = max(odp, Licz(a, i));
  cout << odp;
  return 0;
}
