#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e6 + 6;
int in[MAXN];
int n;
string s;
int p[MAXN];
int sz[MAXN];
int stk[MAXN];
int ptr = 0;
int find_set(int v) { return (v == p[v]) ? v : p[v] = find_set(p[v]); }
void unite(int v, int u) {
  v = find_set(v);
  u = find_set(u);
  if (v == u) return;
  if (sz[v] > sz[u]) swap(v, u);
  p[v] = u;
  sz[u] += sz[v];
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(in, 0, sizeof(in));
  cin >> s;
  n = (int)s.length();
  for (auto i = 0; i != n; i++) {
    p[i] = i;
    sz[i] = 1;
    if (s[i] == '0')
      in[(i + 1) % n]++;
    else
      in[i]++;
  }
  int ans = 0;
  for (auto i = 0; i != n; i++)
    if (in[i] != 1) {
      stk[ptr++] = i;
    }
  for (auto i = 0; i != ptr; i++) {
    int j = (i + 1) % ptr;
    if ((stk[j] - stk[i] + n) % n == 1) unite(stk[i], stk[j]);
  }
  for (auto i = 0; i != ptr; i++) {
    int s = sz[find_set(stk[i])];
    ans += s / 2 + s % 2;
    sz[find_set(stk[i])] = 0;
  }
  cout << ans;
  return 0;
}
