package m.shin; import java.util.Scanner; public class Con531 { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt() , m = s.nextInt(); s.close(); if(n == m){ System.out.println(1); }else if(n % 2 == 0 && m >= n / 2){ System.out.println(2); }else{ System.out.println(-1); } } }