#include <bits/stdc++.h>
using namespace std;
long long MOD = 1e9 + 7;
long long MAX = 1e17;
bool vis[1000005];
int in[1000005], out[1000005], ans;
void dfs(int a, vector<vector<int> > &v) {
  vis[a] = true;
  for (int i = 0; i < v[a].size(); i++)
    if (!vis[v[a][i]]) dfs(v[a][i], v);
}
int main() {
  ios_base::sync_with_stdio(0);
  ;
  vector<vector<int> > v(1000005), r(1000005);
  string s;
  cin >> s;
  int n = s.size();
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      v[i].push_back((i + 1) % n);
      r[(i + 1) % n].push_back(i);
      in[(i + 1) % n]++;
      out[i]++;
    } else {
      r[i].push_back((i + 1) % n);
      v[(i + 1) % n].push_back(i);
      out[(i + 1) % n]++;
      in[i]++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (in[i] > 0 and out[i] > 0 and !vis[i]) {
      dfs(i, v), dfs(i, r), ans++;
    }
  }
  for (int i = 0; i < n; i++) {
    if (!vis[i]) dfs(i, v), dfs(i, r), ans++;
  }
  cout << ans;
}
