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