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