import Data.List main = do [a1,a2,a3] <- map read . words <$> getLine putStrLn $ maybe "INF" show (kadomatsu a1 a2 a3) kadomatsu a1 a2 a3 | isKadomatsu a1 a2 a3 = Nothing | not (isDistinct a1 a2 a3) = Just 0 | otherwise = Just $ length $ filter (\p -> isKadomatsu (mod a1 p) (mod a2 p) (mod a3 p)) [3..amax] where amax = maximum [a1,a2,a3] isKadomatsu a1 a2 a3 = isDistinct a1 a2 a3 && not (isSorted a1 a2 a3) isDistinct a1 a2 a3 = a1/=a2 && a2/=a3 && a3/=a1 isSorted a1 a2 a3 = [a1,a2,a3] == sort [a1,a2,a3] || [a1,a2,a3] == (reverse . sort) [a1,a2,a3]