#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization("unroll-loops")
long long power(long long b, long long e, long long m) {
  if (b == 0) return 0;
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b % m, e / 2, m) % m;
  return power(b * b % m, e / 2, m);
}
long long power(long long b, long long e) {
  if (b == 0) return 0;
  if (e == 0) return 1;
  if (e & 1) return b * power(b * b, e / 2);
  return power(b * b, e / 2);
}
bool isPowerOfTwo(long long x) { return (x && !(x & (x - 1))); }
void solve() {
  long long n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << 1;
    return;
  }
  if (m - 1 < n - m)
    cout << m + 1;
  else
    cout << m - 1;
}
int main() {
  long long tt = 1;
  while (tt--) {
    solve();
    cout << "\n";
  }
}
