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