#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a, long long b) {
  if (b == 0) return a;
  return (a % b == 0 ? b : GCD(b, a % b));
}
long long POW(long long base, long long exp) {
  long long val;
  val = 1;
  while (exp > 0) {
    if (exp % 2 == 1) {
      val = (val * base) % 1000000007;
    }
    base = (base * base) % 1000000007;
    exp = exp / 2;
  }
  return val;
}
int main() {
  int n, m, ans;
  scanf("%d%d", &n, &m);
  if (n == 1) {
    ans = 1;
  } else {
    if ((m - 1) >= (n - m)) {
      ans = m - 1;
    } else {
      ans = m + 1;
    }
  }
  printf("%d\n", ans);
  return 0;
}
