#include int main(){ int n, m;; scanf("%d %d", &n, &m); if(m <= 2 && n != 1){ printf("-1\n"); }else if(n <= m){ printf("1\n"); }else if(m >= n/2 && n%2 == 0){ printf("2\n"); }else{ printf("-1\n"); } return 0; }