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