#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int otvet;
  if (n == 1)
    otvet = 1;
  else if (n - m > m - 1)
    otvet = m + 1;
  else
    otvet = m - 1;
  cout << otvet;
  return 0;
}
