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