#include <bits/stdc++.h>
using namespace std;
int main() {
  long long n, m;
  cin >> n >> m;
  if (m == 1) {
    if (n > 1)
      cout << m + 1 << "\n";
    else
      cout << "1\n";
  } else if (m == n) {
    if (n > 1)
      cout << m - 1 << "\n";
    else
      cout << "1\n";
  } else {
    long long v1 = m - 1, v2 = n - m - 1;
    if (v1 > v2)
      cout << m - 1 << "\n";
    else
      cout << m + 1 << "\n";
  }
  return 0;
}
