#include <bits/stdc++.h>
using namespace std;
char s[2000005];
int ans;
int main() {
  scanf("%s", s + 1);
  int n = strlen(s + 1);
  if (n == 1) {
    puts("1");
    return 0;
  }
  int l = 0;
  for (int i = 1; i <= n; i++) s[n + i] = s[i];
  s[0] = s[n], s[n + n + 1] = s[1];
  for (int i = n + 1; i; i--) {
    if (s[i] == s[i + 1] && s[i] != s[i - 1]) {
      l = i;
      break;
    }
  }
  int t = l + n - 1;
  for (int i = l; i <= t; i++) {
    int len = 0;
    while (s[i] == s[i + 1] && i <= t) {
      s[i] = '2';
      i++;
      len++;
    }
    if (len) {
      ans++;
      s[i] = '2';
    }
  }
  for (int i = l; i <= t; i++) {
    int len = 0;
    while (s[i] != '2' && i <= t) {
      i++;
      len++;
    }
    ans += len / 2;
  }
  printf("%d", ans);
  return 0;
}
