#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cout.precision(10);
  cout << fixed;
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  int right = n - m;
  int left = m - 1;
  int a = 0;
  if (left > right)
    a = m - 1;
  else if (right > left)
    a = m + 1;
  else
    a = m - 1;
  cout << a << endl;
  return 0;
}
