import Control.Applicative ((<$>)) isKadoSeq :: (Integral a, Ord a) => [a] -> Bool isKadoSeq xs @ (a : b : c : []) = c1 && c2 where c1 = a /= b && b /= c && c /= a c2 = b == (maximum xs) || b == (minimum xs) isKadoSeq _ = False countP :: (Integral a, Ord a) => [a] -> Maybe a countP xs | isKadoSeq xs = Nothing | otherwise = Just $ sum [1 | p <- [1 .. maximum xs], isKadoSeq $ map (`mod` p) xs] main :: IO () main = do xs <- map read . words <$> getLine case countP xs of Just n -> print n Nothing -> putStrLn "INF"