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