fun main(args:Array<String>?): Unit {
    val leftHand = "qwertasdfgzxcvb"
    val isLeft = ('a' .. 'z').map{ it in leftHand }.toBooleanArray()
    while(true){
        val s = readLine()!!.trim()
        if (s == "#") return
        println((1 until s.length).count{i -> isLeft[s[i].toIndex] != isLeft[s[i - 1].toIndex]})
    }
}
val Char.toIndex
    get() = this - 'a'
