#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int n = s.length();
  bool dif = false, neighbor = false;
  int start = -1;
  for (int i = 0; i + 1 < n; i++)
    if (s[i] != s[i + 1]) dif = true;
  for (int i = 0; i + 1 < n; i++)
    if (s[i] == s[i + 1]) {
      neighbor = true;
      start = i;
      break;
    }
  if (n % 2 == 1 && !neighbor) {
    neighbor = true;
    start = 0;
  }
  if (!dif) {
    cout << 1 << endl;
    return 0;
  } else if (!neighbor) {
    cout << n / 2 << endl;
    return 0;
  }
  while (s[start] == s[(n + start - 1) % n]) start = (n + start - 1) % n;
  int i = start;
  int len = 1;
  int ans = 0;
  bool skipped = false;
  do {
    while (s[i] == s[(i + 1) % n]) {
      i = (i + 1) % n;
      len++;
    }
    if (len > 1) {
      ans++;
      skipped = false;
    } else {
      if (!skipped)
        skipped = true;
      else {
        ans++;
        skipped = false;
      }
    }
    i = (i + 1) % n;
    len = 1;
  } while (i != start);
  cout << ans << endl;
  return 0;
}
