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