#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int o;
  int u, l, uc, lc;
  u = min(m + 1, n);
  l = max(m - 1, 1);
  uc = n - u;
  lc = l - 1;
  if (uc == lc)
    if (l != m)
      o = l;
    else
      o = u;
  else if (uc > lc)
    o = u;
  else
    o = l;
  cout << o << "\n";
  return 0;
}
