#include <bits/stdc++.h>
using namespace std;
int n;
char s[1000010];
bool gone[1000010];
int Next(int i) { return i == n - 1 ? 0 : i + 1; }
int Prev(int i) { return i == 0 ? n - 1 : i - 1; }
int main() {
  scanf("%s", s);
  n = strlen(s);
  int ret = 0;
  for (int i = 0; i < n; i++) {
    if (gone[i]) continue;
    int prv = Prev(i);
    if (s[i] == '0' && s[prv] == '0') {
      ret++;
      gone[i] = 1;
      for (int j = Next(i); s[Prev(j)] == '0'; j = Next(j)) gone[j] = 1;
      for (int j = i; s[j] == '0'; j = Prev(j)) gone[j] = 1;
    } else if (s[i] == '1' && s[prv] == '1') {
      ret++;
      gone[i] = 1;
      for (int j = Next(i); s[Prev(j)] == '1'; j = Next(j)) gone[j] = 1;
      for (int j = i; s[j] == '1'; j = Prev(j)) gone[j] = 1;
    }
  }
  for (int i = 0; i < n; i++)
    if (!gone[i]) {
      ret++;
      gone[i] = 1;
      for (int j = Next(i); s[Prev(j)] == s[i]; j = Next(j)) gone[j] = 1;
      for (int j = Prev(i); s[j] == s[Prev(i)]; j = Prev(j)) gone[j] = 1;
    }
  printf("%d", ret);
  return 0;
}
