#include <bits/stdc++.h>
using namespace std;
string s;
int t2[2], t[2];
vector<int> type;
int main() {
  cin >> s;
  int n = s.length();
  int c = 1;
  while (c < n && s[c] == s[0]) c++;
  if (c == n) {
    cout << "0\n";
    return 0;
  }
  int prev = 0;
  for (int i = 1; i < n; i++) {
    int ind = (c + i) % n;
    if (s[(prev + c) % n] != s[ind]) {
      if (i - prev <= 1)
        type.push_back(0);
      else
        type.push_back(1);
      prev = i;
    }
  }
  if (n - prev <= 1)
    type.push_back(0);
  else
    type.push_back(1);
  c = 1;
  while (c < type.size() && type[c] == type[0]) c++;
  c %= n;
  int ans = 0;
  prev = 0;
  for (int i = 1; i < type.size(); i++) {
    int ind = (c + i) % type.size();
    if (type[ind] != type[(prev + c) % type.size()]) {
      if (type[(prev + c) % type.size()] == 0)
        ans += (i - prev) / 2;
      else
        ans += i - prev;
      prev = i;
    }
  }
  if (type[(prev + c) % type.size()] == 0)
    ans += (type.size() - prev) / 2;
  else
    ans += type.size() - prev;
  cout << ans << "\n";
}
