import java.math.BigInteger; import java.util.Arrays; import java.util.Scanner; class Main { public static void main(String[] args) { long t = System.currentTimeMillis(); new Main().run(); // new Thread(null, new Main(), "", // Runtime.getRuntime().maxMemory()).start(); System.err.println(System.currentTimeMillis() - t); } @SuppressWarnings("unchecked") public void run() { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); if (n <= m) { System.out.println(1); } else if (n % 2 == 0 && n / 2 <= m) { System.out.println(2); } else { System.out.println(-1); } } static void tr(Object... objects) { System.out.println(Arrays.deepToString(objects)); } }