#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:66777216")
using namespace std;
const int N = 1000007;
int n, cnt, ss;
bool flag, del[N];
char d[N];
vector<vector<int> > chains;
void dfs(int u) {
  if (u == ss && flag) return;
  flag = true;
  vector<int> v;
  int i = u;
  while (d[i] == d[u]) {
    v.push_back(i);
    ++i;
    if (i == n) i = 0;
  }
  v.push_back(i);
  chains.push_back(v);
  dfs(i);
}
void go(int u) {
  if (del[u]) return;
  del[u] = true;
  ++cnt;
  go((u + 1) % n);
  go((u - 1 + n) % n);
}
int main() {
  gets(d);
  n = strlen(d);
  bool f = true;
  for (int i = 1; i < n; ++i) f &= (d[i] == d[0]);
  if (f) {
    cout << (n >> 1) << endl;
    return 0;
  }
  int p = 0;
  while (d[p] == d[0]) ++p;
  ss = p;
  dfs(p);
  int ans = 0;
  for (int i = 0; i < (int)(chains).size(); ++i) {
    vector<int> &v = chains[i];
    if ((int)(v).size() > 2) {
      ++ans;
      for (int u : v) del[u] = true;
    }
  }
  for (int i = 0; i < n; ++i) {
    cnt = 0;
    go(i);
    ans += (cnt + 1) / 2;
  }
  printf("%d\n", ans);
  return 0;
}
