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