main = do p <- getLine putStrLn $ if parse p then "Yes" else "No" parse p@(h:t) | null t = False | h == '1' && all (flip elem "345") (init' t) && (flip elem "234") (last' t) = True | all (flip elem "67") (init' p1) && flip elem "78" (last' p1) && all (flip elem "345") (init' p2) && (flip elem "234") (last' p2) = True | otherwise = False where (p1,p2) = break (flip elem "2345") p init' xs = if null xs then [] else init xs last' xs = if null xs then 'x' else last xs