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