#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long m, n;
  cin >> n >> m;
  long long left = abs(m - 1);
  long long right = abs(n - m);
  long long ans = 0;
  if (left >= right)
    ans = m - 1;
  else
    ans = m + 1;
  ans = max(ans, (long long)1);
  cout << ans;
  return 0;
}
