#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 1e6 + 10;
int a[MAX_N];
int b[MAX_N];
int res;
const int BUFSIZE = MAX_N;
char buf[BUFSIZE + 1];
string nextString() {
  scanf("%s", buf);
  return buf;
}
int main() {
  long long n, m;
  cin >> n >> m;
  long long l = m - 1;
  long long r = n - m;
  long long a = -1;
  if (l == r && l == 0)
    a = m;
  else if (l == r && l != 0)
    a = m - 1;
  else if (l < r)
    a = m + 1;
  else
    a = m - 1;
  cout << a << endl;
  return 0;
}
