#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  int ans = 2;
  for (int i = 0; i + 1 < (int)s.size(); i++) {
    if (s[i] != s[i + 1]) {
      ans++;
    }
  }
  cout << min((int)s.size(), ans) << endl;
}
