#include <bits/stdc++.h>
using namespace std;
string s;
int ans, in[1000005], out[1000005], len;
bool vis[1000005];
inline int mod(int x) {
  while (x < 0) {
    x += len;
  }
  return x % len;
}
inline void dfs_zheng(int now) {
  if (vis[now] == true) {
    return;
  }
  vis[now] = true;
  if (s[now] == '0') {
    dfs_zheng(mod(now + 1));
  }
  if (s[mod(now - 1)] == '1') {
    dfs_zheng(mod(now - 1));
  }
}
inline void dfs_dao(int now) {
  if (vis[now] == true) {
    return;
  }
  vis[now] = true;
  if (s[now] == '1') {
    dfs_dao(mod(now + 1));
  }
  if (s[mod(now - 1)] == '0') {
    dfs_dao(mod(now - 1));
  }
}
int main() {
  cin >> s;
  len = s.size();
  for (register int i = 0; i < len; i++) {
    switch (s[i] - '0') {
      case 0:
        in[i]++;
        out[mod(i + 1)]++;
        break;
      case 1:
        in[mod(i + 1)]++;
        out[i]++;
        break;
    }
  }
  for (register int i = 0; i < len; i++) {
    if (vis[i] == true) {
      continue;
    }
    if (in[i] > 0 && out[i] > 0) {
      dfs_zheng(i);
      vis[i] = false;
      dfs_dao(i);
      ans++;
    }
  }
  for (register int i = 0; i < len; i++) {
    if (vis[i] == true) {
      continue;
    }
    dfs_zheng(i);
    vis[i] = false;
    dfs_dao(i);
    ans++;
  }
  printf("%d\n", ans);
  return 0;
}
