#include <bits/stdc++.h>
using namespace std;
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
int exgcd(int a, int b, int &x, int &y) {
  if (b == 0) {
    x = 1;
    y = 0;
    return a;
  }
  int r = exgcd(b, a % b, x, y);
  int t = y;
  y = x - a / b * y;
  x = t;
  return r;
}
inline int lcm(int a, int b) { return a / gcd(a, b) * b; }
inline int max(int a, int b) { return a > b ? a : b; }
inline int min(int a, int b) { return a > b ? b : a; }
inline int abs(int a) { return a > 0 ? a : -a; }
bool leitu(int a, int &x, int b, int &y, int c) {
  int s, t;
  int GCD = exgcd(a, b, s, t);
  if (abs(c) % GCD) return false;
  int s0 = (-s) * c / GCD;
  int t0 = t * c / GCD;
  int B = b / GCD;
  int A = a / GCD;
  if (s0 >= 0 && t0 >= 0) {
    while (s0 - B >= 0 && t0 - A >= 0) {
      s0 -= B;
      t0 -= A;
    }
  } else {
    while (!(s0 >= 0 && t0 >= 0)) {
      s0 += B;
      t0 += A;
    }
  }
  x = s0;
  y = t0;
  return true;
}
const int matrix_size = 4;
class matrix {
 public:
  long long mat[matrix_size][matrix_size];
  matrix() { memset(mat, 0, sizeof(mat)); }
  matrix(long long a[matrix_size][matrix_size]) {
    for (int i = 0; i < matrix_size; i++) {
      for (int j = 0; j < matrix_size; j++) {
        mat[i][j] = a[i][j];
      }
    }
  }
  friend matrix matrix_mul(matrix m1, matrix m2, long long mod) {
    matrix t;
    for (int i = 0; i < matrix_size; i++) {
      for (int j = 0; j < matrix_size; j++) {
        for (int k = 0; k < matrix_size; k++) {
          t.mat[i][j] += m1.mat[i][k] * m2.mat[j][k] % mod;
          t.mat[i][j] %= mod;
        }
      }
    }
    return t;
  }
  friend matrix matrix_pow(matrix m, long long p, long long mod) {
    matrix ans;
    for (int i = 0; i < matrix_size; i++) ans.mat[i][i] = 1;
    while (p) {
      if (p & 1) {
        ans = matrix_mul(ans, m, mod);
      }
      m = matrix_mul(m, m, mod);
      p >>= 1;
    }
    return ans;
  }
};
int main() {
  int n, m;
  cin >> n >> m;
  int ans;
  if (m - 1 >= n - m)
    ans = m - 1;
  else
    ans = m + 1;
  if (ans < 1 || ans > n) ans = 1;
  cout << ans << endl;
  return 0;
}
