import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import static java.lang.System.in; public class No531 { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String[] inputs = reader.readLine().split(" "); int n = Integer.parseInt(inputs[0]); int m = Integer.parseInt(inputs[1]); if (n <= m) { System.out.println(1); } else { if (n % 2 == 0 && n / 2 <= m) { if ((n / 2) % m == 0) { System.out.println((n / 2) / m + 1); } else { System.out.println((n / 2) / m + 2); } } else { System.out.println(-1); } } } }