#include <bits/stdc++.h>
using namespace std;
int n, x;
void solve() {
  cin >> n >> x;
  int left = x - 1;
  int right = n - x;
  if (left >= right)
    cout << (x - 1 == 0 ? 1 : x - 1) << endl;
  else
    cout << (x + 1 > n ? n : x + 1) << endl;
}
int main() {
  ios_base ::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
  ;
  int tt;
  tt = 1;
  for (int i = 1; i <= tt; ++i) {
    solve();
  }
  return 0;
}
