main = interact $ unlines . map (show . ac) . init . lines

ac = sum . compress change

change k1 k2 = if elem k1 left `xor` elem k2 left then 1 else 0
 where
  left = "qwertasdffgzxcvb"
  xor p q = (p || q) && not (p && q)

compress _ [x] = []
compress op (x1:x2:xs) = op x1 x2 : compress op (x2:xs)