#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
char s[N];
int n, ans, vis[N], in[N], out[N];
void dfs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  if (s[x] == '0') dfs((x + 1) % n);
  if (s[(x - 1 + n) % n] == '1') dfs((x - 1 + n) % n);
}
void dfs2(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  if (s[x] == '1') dfs2((x + 1) % n);
  if (s[(x - 1 + n) % n] == '0') dfs2((x - 1 + n) % n);
}
int main() {
  scanf("%s", s);
  n = strlen(s);
  for (int i = 0; i < n; i++) {
    if (s[i] == '0')
      in[(i + 1) % n]++, out[i]++;
    else
      in[i]++, out[(i + 1) % n]++;
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    if (in[i] && out[i]) {
      dfs(i);
      vis[i] = 0;
      dfs2(i);
      ans++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (vis[i]) continue;
    ans++;
    dfs(i);
    vis[i] = 0;
    dfs2(i);
  }
  printf("%d", ans);
  return 0;
}
