#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 29;
char str[1000010];
int in[1000010], vis[1000010];
vector<int> e;
int main() {
  scanf("%s", str);
  int n = strlen(str);
  for (int i = 0; str[i]; i++) {
    if (str[i] == '0') {
      in[(i + 1) % n]++;
    } else
      in[i]++;
  }
  for (int i = 0; i < n; i++) {
    if (in[i] != 1) e.push_back(i);
  }
  int ans = 1;
  int pre = 1;
  for (int i = 1; i < e.size(); i++) {
    if (i <= pre)
      continue;
    else {
      if (e[i] - e[i - 1] <= 1 && i == e.size() - 1) continue;
      ans++;
      if (e[i] - e[i - 1] > 1)
        pre = i;
      else
        pre = i + 1;
    }
  }
  int sum = 0;
  pre = 0;
  for (int i = 1; i < e.size(); i++) {
    if (i <= pre)
      continue;
    else {
      sum++;
      if (e[i] - e[i - 1] > 1)
        pre = i;
      else
        pre = i + 1;
    }
  }
  if (pre == e.size() - 1)
    if ((e[0] + n - e[e.size() - 1]) % n > 1) sum++;
  printf("%d\n", max(ans, sum));
}
