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