#include <bits/stdc++.h>
using namespace std;
const long long MAXN = 1e5 + 100;
long long n, m;
int main() {
  cin >> n >> m;
  if (n == 1)
    cout << "1";
  else if (m > n / 2)
    cout << m - 1;
  else
    cout << m + 1;
}
