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