#include <bits/stdc++.h>
using namespace std;
int n;
char dir[1000010];
bool liber[1000010];
int main() {
  cin >> dir;
  n = strlen(dir);
  int ans(0);
  for (int i(0); i < n; i++) {
    if (!liber[i] && dir[i] == dir[((i - 1 + n) % n)]) {
      ans++;
      for (int j(i);; j = ((j + 1) % n)) {
        liber[j] = 1;
        if (dir[j] != dir[i]) break;
      }
      for (int j(((i - 1 + n) % n)); dir[j] == dir[i]; j = ((j - 1 + n) % n))
        liber[j] = 1;
    }
  }
  for (int i(0); i < n; i++) {
    if (!liber[i]) {
      ans++;
      for (int j(i);; j = ((j + 1) % n)) {
        liber[j] = 1;
        if (dir[j] != dir[i]) break;
      }
      for (int j(((i - 1 + n) % n)); dir[j] == dir[((i - 1 + n) % n)];
           j = ((j - 1 + n) % n))
        liber[j] = 1;
    }
  }
  cout << ans << '\n';
  return 0;
}
