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