#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read() {
  char c = getchar();
  long long tot = 1;
  while ((c < '0' || c > '9') && c != '-') c = getchar();
  if (c == '-') {
    tot = -1;
    c = getchar();
  }
  long long sum = 0;
  while (c >= '0' && c <= '9') {
    sum = sum * 10 + c - '0';
    c = getchar();
  }
  return sum * tot;
}
inline void wr(long long x) {
  if (x < 0) {
    putchar('-');
    wr(-x);
    return;
  }
  if (x >= 10) wr(x / 10);
  putchar(x % 10 + '0');
}
inline void wrn(long long x) {
  wr(x);
  putchar('\n');
}
inline void wri(long long x) {
  wr(x);
  putchar(' ');
}
inline void wrn(long long x, long long y) {
  wri(x);
  wrn(y);
}
inline void wrn(long long a, long long b, long long c) {
  wri(a);
  wrn(b, c);
}
long long n, m, ans, q, z[1000055], b[1000055], tot, num;
char str[1000055];
signed main() {
  scanf("%s", str + 1);
  n = strlen(str + 1);
  for (long long i = (1); i <= (n); i++) {
    if (i == 1 || str[i] != str[i - 1])
      z[++tot] = 1;
    else
      z[tot] = 0;
  }
  if (str[n] == str[1]) z[1] = 0, tot--;
  long long t = 1;
  for (long long i = (1); i <= (tot); i++) {
    if (z[i] == 1) {
      t = i;
      break;
    }
  }
  for (long long i = (t); i <= (tot); i++) b[++num] = z[i];
  for (long long i = (1); i <= (t - 1); i++) b[++num] = z[i];
  for (long long i = (1); i <= (num); i++) {
    if (b[i] == 1)
      q++;
    else {
      ans += (q >> 1) + 1;
      q = 0;
    }
  }
  wrn(ans + (q >> 1));
  return 0;
}
