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