"use strict";
const Main = (input) =>{
   let xs = input.trim().split('');
   let len = xs.length;
   let S = '';
   let cnt = 0;
   for(let i=0; i<len; i++){
     S=xs[i]+xs[i+1];
     if(S=='WB'|| S=='BW'){
       cnt +=1;
     }else{
       cnt +=0;
     }
   }
   console.log(cnt);
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));