#include <bits/stdc++.h>
using namespace std;
int MOD = 1000000007;
long long m, n;
int main() {
  scanf("%164d %164d", &m, &n);
  if (n == 1 && m == 1)
    cout << 1;
  else {
    if (n > (m - n))
      cout << n - 1;
    else
      cout << n + 1;
  }
  return 0;
}
