#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:640000000")
using namespace std;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int maxn = (int)1e6 + 10;
char s[maxn * 2];
bool used[maxn * 2];
int main() {
  scanf("%s", s);
  int n = strlen(s);
  if (n == 2) {
    cout << 1 << endl;
    return 0;
  }
  for (int i = 0; i < n; i++) {
    s[i + n] = s[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') cnt++;
  }
  if (cnt == n || cnt == 0) {
    cout << 1 << endl;
    return 0;
  }
  int start = 1;
  while (s[start - 1] == s[start]) start++;
  for (int i = start; i < start + n; i++) {
    s[i - start] = s[i];
  }
  int res = 0;
  for (int i = 0; i < n;) {
    int j = i;
    while (j < n && s[i] == s[j]) j++;
    if (j - i >= 2) {
      res++;
      while (i < j) {
        used[i] = true;
        i++;
      }
      used[i % n] = true;
    }
    i = j;
  }
  for (int i = 0; i < n; i++) {
    used[i + n] = used[i];
  }
  start = 0;
  while (start < n && !used[start]) start++;
  if (start == n) {
    cout << res + n / 2 << endl;
    return 0;
  }
  while (start < n && used[start]) start++;
  if (start != n) {
    for (int i = start; i < start + n;) {
      int j = i;
      while (j < start + n && !used[j]) j++;
      res += (j - i + 1) / 2;
      i = j;
      while (i < n + start && used[i]) i++;
    }
  }
  cout << res << endl;
  return 0;
}
