let n = readLine()!.split(separator: " ").map{Int($0)!} print(n[1] > n[0] ? n[1]-1 : -1)