#include using namespace std; int main() { int n, k; cin>>n>>k; cout<<(k<1 or k>n ? 0 : n-2+(k==n-k+1))<