import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner s = new Scanner(System.in); String[] str = s.nextLine().split(" "); int n = Integer.parseInt(str[0]); int m =Integer.parseInt(str[1]); if(m>=n){ System.out.println(1); }else if(n/2<=m && n%2 == 0){ System.out.println(2); }else { System.out.println(-1); } } }