#include <bits/stdc++.h>
using namespace std;
int main() {
  int i, j, k, t, n, b;
  cin >> n >> b;
  if (n == 1 && b == 1) {
    cout << 1 << endl;
    return 0;
  }
  if ((n & 1) && b == n / 2 + 1) {
    cout << n / 2 << endl;
  } else if (n == 2) {
    if (b == 1)
      cout << 2 << endl;
    else
      cout << 1 << endl;
  } else {
    if (b > n / 2)
      cout << b - 1 << endl;
    else
      cout << b + 1 << endl;
  }
  return 0;
}
