#include <bits/stdc++.h>
using namespace std;
int st[1000000];
bool u[1000000];
int main() {
  string s;
  cin >> s;
  int n = (int)s.size();
  for (int i = 0; i < n; i++)
    if (s[i] == '0')
      st[(i + 1) % n]++;
    else
      st[i]++;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (u[i] || st[i] != 1) continue;
    u[i] = 1;
    int now = (i + n - 1) % n;
    while (st[now] == 1 && !u[now]) u[now] = 1, now = (now + n - 1) % n;
    if (now == i) {
      cout << 1;
      return 0;
    }
    if (st[now] != 1) {
      ans++;
      continue;
    }
  }
  for (int i = 0; i < n; i++)
    if (st[i] != 1 && !u[(i + 1) % n] && !u[(i + n - 1) % n]) u[i] = 1, ans++;
  cout << ans;
}
