def lscan; gets.split.map(&:to_i); end
def bye(msg); puts msg.to_s; exit; end
n,k = lscan

bye -1 if n < k
p k-1