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