#include <bits/stdc++.h>
using namespace std;
inline char gc() {
  static char buf[1 << 14], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 14, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline long long read(long long &x) {
  x = 0;
  bool f = 1;
  char c = gc();
  for (; !isdigit(c); c = gc()) {
    if (c == '-') f ^= 1;
    if (c == -1) return -1;
  }
  for (; isdigit(c); c = gc()) x = (x << 1) + (x << 3) + (c ^ 48);
  x = f ? x : -x;
  return 1;
}
inline void wr(long long x) {
  if (x < 0) putchar('-'), x = -x;
  if (x > 9) wr(x / 10);
  putchar(x % 10 | 48);
}
const long long N = 1e6 + 10;
char s[N];
long long a[N], n, tot, num, ans;
int main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (long long i = 1; i <= n; ++i)
    if (s[i] != s[i - 1])
      a[++tot] = 1;
    else
      a[tot] = 0;
  if (s[1] == s[n]) a[1] = 0, --tot;
  for (long long i = 1; i <= tot; ++i)
    if (a[i])
      ++num;
    else
      ans += num / 2 + 1, num = 0;
  wr(ans + num / 2);
  return 0;
}
