#include <iostream> using namespace std; int main() { int N,W; cin >> N >> W; if (N == 1) cout << 0 << endl; else cout << W - 1 << endl; return 0; }