#include <bits/stdc++.h>
using namespace std;
int main() {
  unsigned long long a, b;
  cin >> a >> b;
  if (a == 1) {
    cout << 1;
  } else if (b == 1) {
    cout << 2;
  } else if (b == a) {
    cout << a - 1;
  } else {
    if ((a - b) > (b - 1)) {
      cout << b + 1;
    } else {
      cout << b - 1;
    }
  }
  return 0;
}
