#include <bits/stdc++.h>
using namespace std;
template <typename T, typename T1>
T min(T &a, T1 b) {
  if (b < a) a = b;
  return a;
}
template <typename T, typename T1>
T max(T &a, T1 b) {
  if (b > a) a = b;
  return a;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long n, m;
  cin >> n;
  cin >> m;
  if (n == 1 && m == 1) {
    cout << 1;
  } else if (n - m > m - 1) {
    cout << m + 1;
  } else if (n - m < m - 1) {
    cout << m - 1;
  } else {
    cout << m - 1;
  }
  return 0;
}
