x?(a,b) = if x then a else b

main = do
  s <- getLine
  print $ solve s

solve :: String -> Int
solve s = minimum [from0 s,from1 s]

from0 = df wb
from1 = df bw

df (c:cs) (x:xs) = (c==x)?(0,1)+(null xs)?(0,df cs xs)

wb = cycle ['0','1']
bw = cycle ['1','0']
