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