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