#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int k = m;
  int a1 = n - k;
  int a2 = k - 1;
  if (n == 1) {
    cout << 1;
    return 0;
  }
  if (a1 > a2) {
    cout << k + 1;
    return 0;
  }
  cout << k - 1;
  return 0;
}
