#include <bits/stdc++.h>
using namespace std;
int a, b;
int main() {
  cin >> a >> b;
  if (a == 1 && b == 1) {
    printf("1\n");
    return 0;
  }
  if (a % 2 == 1) {
    int mid = (a >> 1) + 1;
    if (mid > b) printf("%d\n", b + 1);
    if (mid <= b) printf("%d\n", b - 1);
    return 0;
  }
  if (b <= a / 2) {
    printf("%d\n", b + 1);
    return 0;
  }
  printf("%d", b - 1);
  return 0;
}
