#include <bits/stdc++.h>
using namespace std;
const int INF = INT_MAX;
const long long mod = 1e9 + 7;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  int n, m;
  cin >> n >> m;
  if (n == 1)
    m = 1;
  else if (m - 1 >= n - m)
    m--;
  else
    m++;
  cout << m << "\n";
  return 0;
}
