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