solve ns | head ns == '1' && all (=='3') ns' = len_n | otherwise = "-1" where ns' = tail ns len_n = show $ length ns' main = getLine >>= putStrLn . solve