#include #include #include #include #include using namespace std; int main() { int N, K; cin >> N >> K; if (N == 1) { cout << 1 << endl; } else if (N == 2) { cout << (K == 1 ? 2 : 1) << endl; } else { if (2 * K - 1 <= N) { cout << N - 1 << endl; } else { cout << (K != N ? N : N - 1) << endl; } } return 0; }