input = require('fs').readFileSync('/dev/stdin', 'utf8')
S = input.split('\n').shift()
s = ['W', 'B']
b = S[0] == s[1]
cnt = 0
for (i=1;i<S.length;i++) {
    if (s[~~!b] == S[i]) {
        b = !b
        cnt++
    }
}
console.log(cnt)