#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m, a[1000] = {0}, x, maxx = -1, res = 0;
  cin >> n >> m;
  if (m - 1 >= n - m) {
    x = m - 1;
  } else
    x = m + 1;
  if (x == 0) x = 1;
  cout << x << endl;
  return 0;
}
