#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  scanf("%lld %lld", &n, &m);
  if (n == 1)
    printf("1");
  else if ((m - 1) >= (n - m))
    printf("%lld\n", m - 1);
  else
    printf("%lld\n", m + 1);
}
