#include <bits/stdc++.h>
using namespace std;
const int inf = 0x3f3f3f3f3f3f3f3f;
long long power(long long a, long long b) {
  long long res = 1;
  while (b != 0) {
    if (b & 1) {
      res *= a;
    }
    a = (a * a);
    b = (b / 2);
  }
  return res;
}
int32_t main() {
  long long i, j, k, l, n, m, t;
  t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    if (n == 1) {
      cout << 1;
      return 0;
    }
    if (m - 1 < n - m) {
      cout << m + 1;
    } else {
      cout << m - 1;
    }
  }
  return 0;
}
