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