#include #include #include #include #include #include #include #include #include #include #include using namespace std; // Powered by caide (code generator, tester, and library code inliner) class Solution { public: void solve(std::istream& in, std::ostream& out) { int n, k; int ans = 0; in >> n >> k; if (k == 0 || k > n) { ans = 0; } else { ans = n == 2 * k - 1 ? n - 1 : n - 2; } out << ans; } }; void solve(std::istream& in, std::ostream& out) { out << std::setprecision(12); Solution solution; solution.solve(in, out); } #include #include int main() { ios_base::sync_with_stdio(0); cin.tie(0); istream& in = cin; ostream& out = cout; solve(in, out); return 0; }