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