#include <bits/stdc++.h>
using namespace std;
const double pi = 3.14159265358979323;
long long int n, k, m, tc, ans = 0, count = 0, mymax = -1e18, mymin = 1e18;
string final_ans = "";
string s = "";
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  for (int i = 0; i < v.size(); i += 1) os << v[i] << " ";
  os << '\n';
  return os;
}
double fact(int n) {
  if (n == 0)
    return 1;
  else
    return (double)n * fact(n - 1);
}
long long power(long long x, long long y) {
  long long ans = 1;
  while (y > 0) {
    if (y % 2 == 1) ans = (ans * x);
    y /= 2;
    x = (x * x);
  }
  return ans;
}
bool viable(long long int n) {
  while (n % 2 == 0) n /= 2;
  while (n % 3 == 0) n /= 3;
  return (n == 1);
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cin >> n >> m;
  if (n == 1)
    cout << 1;
  else if (n - m > m - 1)
    cout << m + 1;
  else
    cout << m - 1;
}
