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