#include <bits/stdc++.h>
using namespace std;
bool cmp(char a, char b) { return a > b; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  t = 1;
  while (t--) {
    long long int n, m;
    cin >> n >> m;
    if (n == 1) {
      cout << 1 << endl;
    } else {
      if (m - 1 > n - m) {
        cout << m - 1 << endl;
      } else if (m - 1 == n - m) {
        cout << m - 1 << endl;
      } else {
        cout << m + 1 << endl;
      }
    }
  }
}
