#include <bits/stdc++.h>
using namespace std;
long long gcd(long long x, long long y) { return y == 0 ? x : gcd(y, x % y); }
long long mulmod(long long a, long long b, long long c) {
  long long x = 0, y = a % c;
  while (b > 0) {
    if (b % 2 == 1) {
      x = (x + y) % c;
    }
    y = (y * 2) % c;
    b /= 2;
  }
  return x % c;
}
int cmp_2(int a, int b) { return a < b; }
int i, j, x, temp;
long long t;
long long ans = 0;
const int maxn = 105;
int a[maxn];
int main() {
  int n, m;
  cin >> n >> m;
  if (n == 1) {
    cout << "1" << endl;
  } else if (2 * m <= n) {
    cout << m + 1 << endl;
  } else {
    cout << m - 1 << endl;
  }
  return 0;
}
