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