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