#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  int n = s.size();
  vector<int> a;
  for (int i = 0; i < n;) {
    int j = i + 1;
    while (j < n && s[j] == s[i]) ++j;
    a.push_back(j - i);
    i = j;
  }
  if (s.back() == s[0]) {
    a[0] += a.back();
    a.pop_back();
  }
  for (int _n(a.size()), i(0); i < _n; i++) a[i] = min(a[i], 2);
  auto it = find(a.begin(), a.end(), 2);
  if (it == a.end()) {
    cout << a.size() / 2 << endl;
    return 0;
  }
  rotate(a.begin(), it, a.end());
  int ans = 0;
  for (int i = 0; i < a.size();) {
    if (a[i] == 2) {
      ans++;
      i++;
      continue;
    }
    int j = i + 1;
    int cnt = 1;
    while (j < a.size() && a[j] == 1) {
      ++cnt;
      j++;
    }
    ans += cnt / 2;
    i = j;
  }
  cout << ans << endl;
  return 0;
}
