#include #include #include #include #include using namespace std; int main() { std::ios::sync_with_stdio(false); std::cin.tie(0); int n,k; cin >> n >> k; if(k > n || k == 0) cout << 0 << endl; else if(n >= k) cout << (n - 2 > 0 ? n - 2 : 0) << endl; }