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