#include <bits/stdc++.h>
using namespace std;
void op(string &str) {
  while (1) {
    auto pos = str.find("BB");
    if (pos != -1)
      str.replace(pos, 2, "B");
    else
      break;
  }
  while (1) {
    auto pos = str.find("WW");
    if (pos != -1)
      str.replace(pos, 2, "W");
    else
      break;
  }
  return;
}
int main() {
  string str;
  cin >> str;
  op(str);
  printf("%lu\n", str.size() - 1);
  return 0;
}
