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