#include using namespace std; int main(){ int a,b,c; cin >> a >> b; if(b==0||a1&&b>1) c=2; else c=1; cout << a-c << endl; return 0; }