#include <bits/stdc++.h>
using namespace std;
int main() {
  int x[1 + 10], y[1 + 10];
  cin >> x[1] >> y[1];
  if (x[1] - y[1] >= y[1] && x[1] != 1) {
    cout << y[1] + 1;
  } else if (x[1] - y[1] < y[1] && x[1] != 1) {
    cout << y[1] - 1;
  } else if (x[1] == 1) {
    cout << "1" << endl;
  }
}
