module ABC158.C

let nums = stdin.ReadLine().Split(' ') |> Array.map (fun x -> int (x) * 1000)

let seq8 =
    seq { nums.[0] .. (nums.[0] + 999) }
    |> Seq.map (fun x -> x / 8)
    |> Seq.distinct

let seq10 =
    seq { nums.[1] .. (nums.[1] + 999) }
    |> Seq.map (fun x -> x / 10)
    |> Seq.distinct

seq8
|> Seq.filter (fun x -> seq10 |> Seq.contains x)
|> Seq.tryHead
|> function
| Some x -> printf "%d" (x / 10)
| None -> printf "-1"
