#include int main(void){ long int N; // number of boxes long int K; // place of trap long int count = 0; // number of cheeses 'r' can eat scanf("%ld %ld",&N,&K); if(K != 0 && N >= K){ count = N; if(K == N-K+1){ count--; }else{ count -= 2; } } printf("%ld\n",count); return 0; }