#include <bits/stdc++.h>
const int INF = 1e9;
const long long lINF = 1e18;
const double EPS = 1e-10;
using namespace std;
int n, m;
int main() {
  cin >> n >> m;
  if (n == 1) {
    cout << 1 << endl;
  } else {
    if (n - m > m - 1) {
      cout << m + 1 << endl;
    } else {
      cout << m - 1 << endl;
    }
  }
  return 0;
}
