#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll mxr = 1e6 + 10;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int fl, n, m;
  cin >> n >> m;
  fl = n - m;
  if (n == 1) {
    cout << 1 << "\n";
    return 0;
  }
  if (fl > m - 1)
    cout << m + 1 << "\n";
  else
    cout << m - 1 << "\n";
  return 0;
}
