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