#include <bits/stdc++.h>
using namespace std;
char c[1 << 20];
int step[1 << 20];
bool used[1 << 20];
int def[1 << 20];
int main() {
  scanf("%s", c);
  int len = strlen(c);
  for (int i = 0; i < len; i++) {
    if (c[i] == '0')
      step[(i + 1) % len]++;
    else
      step[i]++;
  }
  int cnt = 0;
  for (int i = 0; i < len; i++)
    if (step[i] == 0) {
      int val = 0;
      if (step[(i + 1) % len] != 2) {
        cnt++;
        val++;
      } else {
        if (def[(i + 1) % len] == 1) cnt++, val++;
        def[(i + 1) % len] = 1;
      }
      int v = i - 1;
      if (v < 0) v = len - 1;
      if (step[v] != 2) {
        val++;
        cnt++;
      } else {
        if (def[v] == 1) cnt++, val++;
        def[v] = 1;
      }
      if (val == 0) {
        cnt++;
        def[v] = 0;
        def[(i + 1) % len] = 0;
      }
    }
  cout << cnt << endl;
  return 0;
}
