#include <bits/stdc++.h>
using namespace std;
long long NegMod(long long a, long long b) {
  return a >= 0 ? a % b : (b - abs(a % b)) % b;
}
template <class T>
inline bool read(T &x) {
  int c = getchar();
  int sgn = 1;
  while (~c && c < '0' || c > '9') {
    if (c == '-') sgn = -1;
    c = getchar();
  }
  for (x = 0; ~c && '0' <= c && c <= '9'; c = getchar()) x = x * 10 + c - '0';
  x *= sgn;
  return ~c;
}
int X[] = {-1, -1, -1, 0, 1, 1, 1, 0};
int Y[] = {-1, 0, +1, 1, 1, 0, -1, -1};
int main() {
  long long n, m;
  read(n);
  read(m);
  if (n == 1)
    cout << n << endl;
  else if (m - 1 < n - m)
    cout << m + 1 << endl;
  else
    cout << m - 1 << endl;
  return 0;
}
