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