#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  long long m, n;
  cin >> m >> n;
  long long a = n - 1;
  long long b = m - n;
  if (m == 1)
    cout << "1";
  else if (a >= b)
    cout << a;
  else
    cout << n + 1;
}
