#include <bits/stdc++.h>
using namespace std;
void bug(string m = "here") { cout << m << endl; }
template <typename __ll>
inline void READ(__ll &m) {
  __ll x = 0, f = 1;
  char ch = getchar();
  while (!(ch >= '0' && ch <= '9')) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    x = x * 10 + ch - '0';
    ch = getchar();
  }
  m = x * f;
}
template <typename __ll>
inline void read(__ll &m) {
  READ(m);
}
template <typename __ll>
inline void read(__ll &m, __ll &a) {
  READ(m);
  READ(a);
}
template <typename __ll>
inline void read(__ll &m, __ll &a, __ll &b) {
  READ(m);
  READ(a);
  READ(b);
}
template <typename __ll>
inline void read(__ll &m, __ll &a, __ll &b, __ll &c) {
  READ(m);
  READ(a);
  READ(b);
  READ(c);
}
template <class T>
T gcd(T a, T b) {
  return b ? gcd(b, a % b) : a;
}
template <class T>
T lcm(T a, T b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline void rmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
inline void rmax(T &a, const T &b) {
  if (a < b) a = b;
}
template <class T>
T pow(T a, T b) {
  T r = 1;
  while (b > 0) {
    if (b & 1) r = r * a;
    a = a * a;
    b /= 2;
  }
  return r;
}
template <class T>
T pow(T a, T b, T mod) {
  T r = 1;
  while (b > 0) {
    if (b & 1) r = r * a % mod;
    a = a * a % mod;
    b /= 2;
  }
  return r;
}
int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 1 && m == 1) {
      cout << 1 << endl;
      continue;
    }
    int a = m - 1;
    int b = n - m;
    if (a >= b)
      cout << m - 1 << endl;
    else
      cout << m + 1 << endl;
  }
}
