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