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