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