#include <bits/stdc++.h>
using namespace std;
const int MOD = int(1e9) + 7;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1.0);
const int maxn = 1000001;
int main() {
  int n, m;
  while (cin >> n >> m) {
    if (n == 1 && m == 1) {
      cout << "1" << endl;
      continue;
    }
    int pos;
    if (m - 1 >= n - m)
      pos = m - 1;
    else
      pos = m + 1;
    cout << pos << endl;
  }
  return 0;
}
