l =  "qwertasdfgzxcvb"
while line = gets.chomp do
    break if line == "\#"
    count = 0
    f = l.include?(line[0])
    line.each_char do |c|
        if l.include?(c)
            count += 1 if !f
            f = true
        else
            count += 1 if f
            f = false
        end
    end
    puts count
end