import java.util.*; public class Test10 { public static void main(String[] args){ Scanner sc=new Scanner(System.in); String[] line; line=sc.nextLine().split(" "); int n=Integer.parseInt(line[0]),m=Integer.parseInt(line[1]); int d=-1; if(n<=m) d=1; else if(n%2==0&&n<=m*2) d=2; System.out.println(d); sc.close(); } }