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