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