#include <bits/stdc++.h>
using namespace std;
const int INF = (int)1E9;
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1 && m == 1) {
    cout << 1 << endl;
    return 0;
  }
  if (n % 2 == 1 && m == (n + 1) / 2) {
    cout << m - 1 << endl;
    return 0;
  }
  int le = m - 1;
  int ri = n - m;
  if (le >= ri) {
    cout << m - 1 << endl;
  }
  if (ri > le) {
    cout << m + 1 << endl;
  }
  return 0;
}
