#include <bits/stdc++.h>
using namespace std;
int vis[1000010];
int in[1000010], out[1000010];
string s;
int n, m;
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 dffs(int x) {
  if (vis[x]) return;
  vis[x] = 1;
  if (s[x] == '1') dffs((x + 1) % n);
  if (s[(x - 1 + n) % n] == '0') dffs((x - 1 + n) % n);
}
int main() {
  ios::sync_with_stdio(false);
  int i;
  int ans = 0;
  cin >> s;
  n = s.size();
  for (i = 0; i < n; i++) {
    if (s[i] == '0')
      in[(i + 1) % n]++, out[i]++;
    else
      in[i]++, out[(i + 1) % n]++;
  }
  for (i = 0; i < n; i++) {
    if (vis[i]) continue;
    if (in[i] && out[i]) {
      dfs(i);
      vis[i] = 0;
      dffs(i);
      ans++;
    }
  }
  for (i = 0; i < n; i++) {
    if (vis[i]) continue;
    dfs(i);
    vis[i] = 0;
    dffs(i);
    ans++;
  }
  cout << ans << endl;
}
