#include <bits/stdc++.h>
int main() {
  long long int n, m, a, left, right;
  scanf("%lld%lld", &n, &m);
  left = m - 1;
  right = n - m;
  if (n == 1) {
    a = 1;
  } else if (left >= right) {
    a = m - 1;
  } else {
    a = m + 1;
  }
  printf("%lld\n", a);
  return 0;
}
