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