#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  cin >> n >> m;
  int mid = n / 2 + 1;
  int result = (m < mid) ? m + 1 : (m == 1) ? 1 : m - 1;
  cout << result;
  return 0;
}
