#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  int lm = m - 1;
  int rm = m + 1;
  if (lm >= n - rm + 1) {
    if (lm == 0)
      cout << m << endl;
    else
      cout << lm << endl;
  } else
    cout << rm << endl;
}
