#include <bits/stdc++.h>
using namespace std;
const int N = 1000005;
int n, ideg[N], odeg[N];
char s[N];
bool vis[N];
void dfs1(int pos) {
  if (vis[pos]) return;
  vis[pos] = 1;
  if (s[pos] == '0') dfs1((pos + 1) % n);
  if (s[(pos - 1 + n) % n] == '1') dfs1((pos - 1 + n) % n);
}
void dfs2(int pos) {
  if (vis[pos]) return;
  vis[pos] = 1;
  if (s[pos] == '1') dfs2((pos + 1) % n);
  if (s[(pos - 1 + n) % n] == '0') dfs2((pos - 1 + n) % n);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> s;
  n = strlen(s);
  for (int i = 0; i < n; i++)
    if (s[i] == '0')
      ++odeg[i], ++ideg[(i + 1) % n];
    else
      ++ideg[i], ++odeg[(i + 1) % n];
  int ans = 0;
  for (int i = 0; i < n; i++)
    if (!vis[i] && ideg[i] && odeg[i]) {
      ++ans;
      dfs1(i);
      vis[i] = 0;
      dfs2(i);
    }
  for (int i = 0; i < n; i++)
    if (!vis[i]) {
      ++ans;
      dfs1(i);
      vis[i] = 0;
      dfs2(i);
    }
  cout << ans << endl;
  return 0;
}
