#include <bits/stdc++.h>
using namespace std;
long long expo(long long a, long long b, long long m) {
  long long result = 1;
  while (b) {
    if (b & 1) {
      result = (result * a) % m;
    }
    b = (b >> 1) % m;
    a = (a * a) % m;
  }
  return result;
}
bool comp(pair<int, int> a, pair<int, int> b) { return a.second <= b.second; }
int main() {
  long long m, n;
  cin >> n >> m;
  if (n == 1) {
    cout << 1 << endl;
  } else if (n - m > m - 1) {
    cout << m + 1 << endl;
  } else if (n - m == m - 1) {
    cout << m - 1 << endl;
  } else if (n - m < m - 1)
    cout << m - 1 << endl;
}
