#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  if (n == 1) {
    printf("1\n");
    return 0;
  }
  int l = m - 1;
  int g = n - m;
  int ans;
  if (l >= g && m > 1) {
    ans = m - 1;
  } else {
    ans = m + 1;
  }
  printf("%d\n", ans);
  return 0;
}
