#include <bits/stdc++.h>
using namespace std;
const long long ZERO = 0;
const int Inf = 1000000000;
const long long INF = 1e18;
const long long MOD = 1000000007;
const double PI = 3.1415926535897;
int main() {
  string S;
  cin >> S;
  int ret = 0;
  for (int i = 0; i < S.size() - 1; i++) {
    if (S.at(i) != S.at(i + 1)) {
      ret++;
    }
  }
  ret += 2;
  cout << ret << endl;
}
