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