#include <iostream>

using namespace std;

int main(){
    string in;
    cin >> in ;
    int flag = -1;
    int cnt = 0;
    for ( int i = 0 ; i < in.length() ; i ++ ) {
        int temp = (in[i] == 'B') ? 1 : 0;
        if ( temp != flag ){
            cnt ++;
            flag = temp;
        }
    }
    cout << cnt - 1 << endl;
}