#include <bits/stdc++.h>
using namespace std;
inline int read() {
  int x = 0, f = 0;
  char ch = getchar();
  while (!isdigit(ch)) f |= ch == '-', ch = getchar();
  while (isdigit(ch)) x = x * 10 + (ch ^ 48), ch = getchar();
  return f ? -x : x;
}
int main() {
  int n = read(), m = read();
  if (n == 1 && m == 1) {
    puts("1");
    return 0;
  }
  if (m - 1 >= n - m)
    printf("%d\n", m - 1);
  else
    printf("%d\n", m + 1);
  return 0;
}
