#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, a, f, s;
  cin >> n >> a;
  f = a - 1, s = n - a;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  if (f < s) {
    cout << a + 1;
  } else {
    cout << a - 1;
  }
}
