#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

void solve() {
    ll n, m;
    ll a = 0;
    cin >> n >> m;

    if (n == 1) {
        cout << "1";
        return;
    }

    if (m <= n / 2) {
        a = m + 1;
    } else {
        a = m - 1;
    }

    cout << a;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    solve();
    return 0;
}
