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