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