main = do [n,m] <- map read . words <$> getLine :: IO [Int] if m<3 then print (-1) else if n<=m then print 1 else print (n-m+1)