{-# LANGUAGE BangPatterns, OverloadedStrings #-}

import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C
import Data.Ratio

main :: IO ()
main = do
  [a, b] <- readIntegers
  print $ solve a b

-- a + 1

solve a b = if mina <= x && x <= maxa && minb <= x && x <= maxb
  then x
  else
    if mina <= y && y <= maxa && minb <= y && y <= maxb
      then y
      else -1
  where
    x = min mina minb
    y = max mina minb
    mina = ceiling $ fromRational $ (a % 1) * (100 % 8)
    maxa = (ceiling $ fromRational $ ((a + 1) % 1) * (100 % 8)) - 1
    minb = ceiling $ fromRational $ (b % 1) * (100 % 10)
    maxb = (ceiling $ fromRational $ ((b + 1) % 1) * (100 % 10)) - 1

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine