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