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