#include <bits/stdc++.h>
using namespace std;
int main() {
  int q, w, x, y, re;
  scanf("%d %d", &q, &w);
  x = q - w, y = w - 0;
  if (x > y)
    re = w + 1;
  else if (x < y)
    re = w - 1;
  else
    re = w + 1;
  if (!re) re = 1;
  if (re > q) re = q;
  printf("%d\n", re);
  return 0;
}
