#include <bits/stdc++.h>
using namespace std;
long long rdtsc() {
  long long tmp;
  asm("rdtsc" : "=A"(tmp));
  return tmp;
}
inline int myrand() { return abs((rand() << 15) ^ rand()); }
inline int rnd(int x) { return myrand() % x; }
const int INF = (int)1e9 + 1;
const long double EPS = 1e-9;
const int maxn = (int)1e6 + 10;
char s[maxn + 1];
int used[maxn];
bool solve() {
  if (scanf("%s", s) < 1) {
    return 0;
  }
  int n = (int)strlen(s);
  {
    int pos = find(s, s + n, '0' + !(s[0] - '0')) - s;
    rotate(s, s + pos, s + n);
  }
  assert(s[0] != s[n - 1]);
  for (int i = 0; i < n; ++i) {
    used[i] = 0;
  }
  int was = -1;
  int res = 0;
  for (int i = 0; i < n;) {
    int i0 = i;
    while (i < n && s[i] == s[i0]) {
      ++i;
    }
    if (i - i0 > 1) {
      for (int j = i0; j <= i; ++j) {
        int v = (j >= n) ? j - n : j;
        used[v] = 1;
      }
      ++res;
      if (was == -1) {
        was = i0;
      }
    }
  }
  if (was == -1) {
    assert(!(n & 1));
    printf("%d\n", n / 2);
    return 1;
  }
  rotate(used, used + was, used + n);
  for (int i = 0; i < n; ++i) {
    if (used[i]) {
      continue;
    }
    ++res;
    i += 1;
  }
  printf("%d\n", res);
  return 1;
}
int main() {
  srand(rdtsc());
  while (1) {
    if (!solve()) {
      break;
    }
  }
  return 0;
}
