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