#include <bits/stdc++.h>
using namespace std;
int solve() {
  long long n, m;
  cin >> n >> m;
  long long x = n / 2;
  if (n == 1 && m == 1)
    cout << 1 << endl;
  else if (x < m)
    cout << m - 1 << endl;
  else
    cout << m + 1 << endl;
  return 0;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  while (t--) {
    solve();
  }
  return 0;
}
