#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int n, m;
  cin >> n >> m;
  long long int first = m - 1;
  long long int second = n - m;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (first >= second) {
    cout << (m - 1) << endl;
  } else {
    cout << (m + 1) << endl;
  }
  return 0;
}
