#include <bits/stdc++.h>
using namespace std;
void solutionE();
int main() {
  ios_base::sync_with_stdio(false);
  solutionE();
  return EXIT_SUCCESS;
}
int n, a[1000000], u[1000000];
string s;
void solve() {
  n = s.size();
  memset(a, 0, sizeof(int) * n);
  memset(u, 0, sizeof(int) * n);
  for (int i = 0; i < n; ++i) {
    if (s[i] == '0')
      ++a[(i + 1) % n];
    else
      ++a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
    if (u[i]) continue;
    if (a[i] != 1) continue;
    u[i] = 1;
    int v = (i + 1) % n;
    while (a[v] == 1 && !u[v]) {
      u[v] = 1;
      v = (v + 1) % n;
    }
    if (v == i) continue;
    if (a[v] != 1) {
      ++cnt;
      continue;
    }
  }
  for (int i = 0; i < n; ++i) {
    int il = (i + n - 1) % n;
    int ir = (i + 1) % n;
    if (a[i] != 1 && !u[il] && !u[ir]) {
      u[i] = 1;
      ++cnt;
    }
  }
  cout << max(1, cnt) << endl;
}
void solutionE() {
  for (; cin >> s;) {
    solve();
    cerr << endl;
  }
}
