#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
using namespace std;
namespace ywy {
char str[2000001];
unsigned char bv[2000001], indeg[2000001], outdeg[2000001];
int n;
void dfs(int pt) {
  if (bv[pt]) return;
  bv[pt] = 1;
  if (str[pt] == '0') dfs((pt + 1) % n);
  if (str[(pt - 1 + n) % n] == '1') dfs((pt - 1 + n) % n);
}
void efs(int pt) {
  if (bv[pt]) return;
  bv[pt] = 1;
  if (str[pt] == '1') efs((pt + 1) % n);
  if (str[(pt - 1 + n) % n] == '0') efs((pt - 1 + n) % n);
}
void ywymain() {
  scanf("%s", str);
  n = strlen(str);
  for (register int i = 0; i < n; i++) {
    if (str[i] == '0')
      indeg[(i + 1) % n]++, outdeg[i]++;
    else
      indeg[i]++, outdeg[(i + 1) % n]++;
  }
  int ans = 0;
  for (register int i = 0; i < n; i++) {
    if (bv[i]) continue;
    if (indeg[i] && outdeg[i]) {
      dfs(i);
      bv[i] = 0;
      efs(i);
      ans++;
    }
  }
  for (register int i = 0; i < n; i++) {
    if (bv[i]) continue;
    ans++;
    dfs(i);
    bv[i] = 0;
    efs(i);
  }
  cout << ans << endl;
}
}  // namespace ywy
int main() {
  ywy::ywymain();
  return (0);
}
