#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long double pi = 3.14159265358979323846264338327950288419716939937510;
long long po(long long a, long long b) {
  long long res = 1 % mod;
  a %= mod;
  for (; b; b >>= 1) {
    if (b & (1LL)) res = res * a % mod;
    a = a * a % mod;
  }
  return res;
}
const long double eps = 1e-10;
const int oo = 1000000009;
const long long ooo = 2e18 + 5;
int main() {
  string s;
  cin >> s;
  vector<int> eq, dp;
  eq.resize(s.size());
  dp.resize(s.size());
  eq[0] = (s[0] != s[s.size() - 1]);
  for (int i = 1; i < s.size(); i++) eq[i] = (s[i] != s[i - 1]);
  dp[0] = 0;
  dp[1] = eq[1];
  for (int i = 2; i < s.size(); i++) dp[i] = max(dp[i - 1], dp[i - 2] + eq[i]);
  int ans = dp[s.size() - 1];
  dp[0] = eq[0];
  dp[1] = max(eq[0], eq[1]);
  for (int i = 2; i < s.size() - 1; i++)
    dp[i] = max(dp[i - 1], dp[i - 2] + eq[i]);
  ans = max(ans, dp[s.size() - 2]);
  cout << ans;
  return 0;
}
