#include <bits/stdc++.h>
using namespace std;
const int MAX = 1e5 + 55;
const int inf = 1e9 + 77;
const int MOD = 1e9 + 7;
const double PI = acos(-1.0);
vector<int> months = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
long long int power(long long int x, long long int y) {
  if (y == 0) return 1;
  long long int s = power(x, y / 2);
  s *= s;
  if (y % 2 == 1) s *= x;
  return s;
}
long long int fac(long long int x) {
  long long int pppp = 1;
  for (int i = 2; i <= x; i++) {
    pppp *= i;
  }
  return pppp;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int n, m;
  cin >> n >> m;
  int ans;
  if (n & 1) {
    int mid = (n / 2) + 1;
    if (m == mid) {
      ans = mid - 1;
    } else if (m > mid) {
      ans = m - 1;
    } else {
      ans = m + 1;
    }
  } else {
    int mid = (n / 2);
    if (m <= mid) {
      ans = m + 1;
    } else {
      ans = m - 1;
    }
  }
  if (n == 1) {
    ans = 1;
  }
  cout << ans;
  return 0;
}
