#include <bits/stdc++.h>
using namespace std;
const int inf = 2000000000;
const int MOD = 100000000;
long long n, m, k, c = 1, q;
vector<pair<int, int> > v;
int main() {
  cin >> n >> k;
  if (k == 1) {
    if (n == 1)
      cout << 1;
    else
      cout << 2;
  } else {
    if (n - k > k - 1) {
      cout << k + 1;
    } else
      cout << k - 1;
  }
  return 0;
}
