#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
void fastio() {
  ios_base ::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
}
long long dp[101][1001], ans1 = 1e10, dp1[1000001];
long long num[10];
signed main() {
  fastio();
  long long t = 1;
  while (t--) {
    long long n, m;
    cin >> n >> m;
    if (n == 1)
      cout << 1;
    else if (m - 1 < n - m)
      cout << m + 1;
    else
      cout << m - 1;
  }
}
