#include #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; int main() { int K, N, ans; cin >> N >> K; if (N == 1) { ans = 1; } else if (N == 2) { ans = 3 - K; } else { if (K == N - 1) ans = N; else ans = N - 1; } cout << ans << endl; }