#include <bits/stdc++.h>
using namespace std;
const int BIG = 1e5 + 55;
const int BIGG = 1e9 + 55;
const long long BIGGE = 1e12 + 55;
const double SML = (1e-7);
int n, m, a;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> n >> m;
  if (n == 1) {
    a = 1;
  } else {
    if (n - m > m - 1) {
      a = m + 1;
    } else {
      a = m - 1;
    }
  }
  cout << a;
  return 0;
}
