#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  long n, m;
  cin >> n >> m;
  if (n == 1)
    cout << 1 << "\n";
  else if (m > n / 2)
    cout << m - 1 << "\n";
  else
    cout << m + 1 << "\n";
  return 0;
}
