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