#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long uu = 0;
  for (long long i = 1; i < s.size(); i++) {
    if (s[i] != s[i - 1]) {
      uu++;
    }
  }
  if (s.size() == 1) {
    cout << 1 << endl;
  } else
    cout << uu + 2 << endl;
}
