#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
typedef vector<int> VI;
typedef vector<VI> VII;
typedef long long ll;
template <class T>
bool chmax(T &map<int, int> MP;, const T &b) {
  if (map<int, int> MP; < b) {
    map<int, int> MP;
    = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &map<int, int> MP;, const T &b) {
  if (b < map<int, int> MP;) {
    map<int, int> MP;
    = b;
    return 1;
  }
  return 0;
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i < v.size() - 1 ? ", " : "");
  }
  os << "}";
  return os;
}
template <typename T>
bool all_same(vector<T> v1, vector<T> v2) {
  sort((v1).begin(), (v1).end());
  sort((v2).begin(), (v2).end(), greater<T>());
  return v1 == v2;
}
ll Max = -1e9, Min = 1e9 + 1;
int main() {
  ll x, c, y = 0, n, m, l, w, sum = 0, sum2 = 0, ans = 0;
  string s, t;
  bool fw = false, fb = false;
  cin >> s;
  if (s.find_first_not_of(s[0])) {
    cout << 0 << endl;
    return 0;
  }
  for (int i = 0; i < s.size(); i++) {
    if (s[i] == 'W') {
      if (fw == true) {
        if (fb == true) {
          sum++;
        }
        fb = false;
      } else {
        if (fb == true) {
          sum2++;
        }
        fb = false;
      }
      fw = true;
    } else {
      fb = true;
    }
  }
  if (fb == true) {
    sum2++;
  }
  cout << sum * 2 + sum2 << endl;
  return 0;
}
