#include <bits/stdc++.h>
using namespace std;
long long int ar[200001];
long long int i, j, k, l, x, y, n, m, a, b;
int main() {
  cin >> n >> m;
  if (n - m > m - 1) {
    cout << m + 1 << endl;
  } else if (n == 1 && m == 1) {
    cout << 1 << endl;
  } else {
    cout << m - 1 << endl;
  }
  return 0;
}
