#include <bits/stdc++.h>
int n, m;
int main() {
  while (~scanf("%d%d", &n, &m)) {
    if (n == 1)
      puts("1");
    else if (2 * m <= n)
      printf("%d\n", m + 1);
    else
      printf("%d\n", m - 1);
  }
  return 0;
}
