#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 30, Mod = 1e9 + 7;
const long long SQ = 330;
int main() {
  ios::sync_with_stdio(0), cin.tie(0);
  string s;
  cin >> s;
  long long n = s.size();
  if (n == 1) return cout << 1, 0;
  if (n == 2 && s[0] == s[1]) return cout << 1, 0;
  long long cur = 0;
  for (int i = 0; i < n - 1; i++) {
    cur += (s[i] != s[i + 1]);
  }
  cout << cur + 2;
  return (0);
}
