import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.PriorityQueue; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); final long n = sc.nextLong(); final long m = sc.nextLong(); if(n == m){ System.out.println(1); }else if(n % 2 == 1){ System.out.println(-1); }else if(n / 2 > m){ System.out.println(-1); }else{ System.out.println(2); } } }