#include <bits/stdc++.h>
int compare(const void* a, const void* b) { return (*(int*)a - *(int*)b); }
int main() {
  long long range, m_choice;
  char buffer[52];
  fgets(buffer, sizeof(buffer), stdin);
  range = atoll(strtok(buffer, " "));
  m_choice = atoi(strtok(NULL, " "));
  if (m_choice == 1 && range == 1) {
    printf("%s", "1");
  } else if (m_choice > abs(range - m_choice)) {
    printf("%lli", --m_choice);
  } else {
    printf("%lli", ++m_choice);
  }
  return 0;
}
