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