#include <bits/stdc++.h>
using namespace std;
const int N = 2 * 1e5 + 10;
const long long inf = 9e18 + 9;
long long res;
long long a[N];
void solve() {
  long long n, a;
  cin >> n >> a;
  if (n == 1) {
    cout << 1;
    return;
  }
  long long ans = abs(1 - a) >= abs(n - a) ? a - 1 : a + 1;
  cout << ans << "\n";
}
int main(int argc, char const *argv[]) {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
