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