#include <bits/stdc++.h>
using namespace std;
struct _comp {
  bool operator()(int i, int j) { return (i > j); }
} comp;
int gcd(int a, int b) {
  if (b == 0)
    return a;
  else
    return gcd(b, a % b);
}
int users_langs[101];
int node_size[101];
void make_set(int a) {
  users_langs[a] = a;
  node_size[a] = 1;
}
int find_set(int a) {
  if (a == users_langs[a]) return a;
  return users_langs[a] = find_set(users_langs[a]);
}
void union_sets(int a, int b) {
  a = find_set(a);
  b = find_set(b);
  if (a != b) {
    if (node_size[a] > node_size[b]) swap(a, b);
    users_langs[b] = a;
    node_size[a] += node_size[b];
  }
}
vector<vector<int>> Ptriangle;
void fill_Ptriangle(int step) {
  vector<int> tmp(1, 1);
  Ptriangle.push_back(tmp);
  for (int i = 1; i <= step; i++) {
    tmp.clear();
    tmp.push_back(1);
    for (int k = 0; k < Ptriangle[i - 1].size() - 1; k++) {
      tmp.push_back(Ptriangle[i - 1][k] + Ptriangle[i - 1][k + 1]);
    }
    tmp.push_back(1);
    Ptriangle.push_back(tmp);
  }
}
string i2s(int a) {
  string s = "";
  if (a < 0) {
    s += '-';
    a = abs(a);
  }
  while (a) {
    s += a % 10 + '0';
    a /= 10;
  }
  return s;
}
int b[101];
int main() {
  int m, n;
  cin >> n >> m;
  if (n == 1) {
    cout << 1 << endl;
    return 0;
  }
  int c = 0;
  if (n % 2) c = 1;
  if (m % 2 == 0)
    if (m <= (n / 2)) {
      cout << m + 1 << endl;
    } else {
      cout << m - 1 << endl;
    }
  else if (m < (n / 2 + 1)) {
    cout << m + 1 << endl;
  } else {
    cout << m - 1 << endl;
  }
  return 0;
}
