#include #include using namespace std; int main() { int N, M; cin >> N >> M; cout << min(M, (N - 1) / 2) << endl; }