import Data.Ratio

solve :: Int -> Int -> Int -> Int
solve a b i
    | i > 100 = -1
    | x && y = i
    | otherwise = solve a b (i+1)
        where
            x = (floor $ (i * 8) % 100) == a
            y = (floor $ (i * 10) % 100)  == b

main = do
    [a,b] <- map read . words <$> getLine :: IO [Int]
    print $ solve a b 1 