#include using namespace std; int main(void){ int N, K; cin >> N >> K; if(K > N || K <= 0) { cout << 0 << endl; }else{ cout << N - 2 << endl; } return 0; }