#include <bits/stdc++.h>
using namespace std;
const int maxn = 100005;
int x[maxn];
int y[maxn];
int z[maxn];
int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 1) {
      cout << 1 << endl;
    } else {
      if (m <= n / 2) {
        cout << m + 1 << endl;
      } else {
        cout << m - 1 << endl;
      }
    }
  }
  return 0;
}
