#include <bits/stdc++.h>
using namespace std;
int a, m, n;
int tpp(bool x) {
  if (x) {
    if (m - 1)
      return 2 * m - 2;
    else
      return 0;
  } else {
    if (m == n)
      return 0;
    else
      return 2 * n - 2 * m;
  }
}
int main() {
  cin >> n >> m;
  if (n == 1)
    cout << 1 << endl;
  else {
    if (tpp(1) >= tpp(0)) {
      if (m == 1)
        cout << 1 << endl;
      else
        cout << m - 1 << endl;
    } else {
      if (m == n)
        cout << m << endl;
      else
        cout << m + 1 << endl;
    }
  }
  return 0;
}
