#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
class BSimpleGame {
 public:
  void solve(std::istream& in, std::ostream& out) {
    long long int n, m, i, j;
    in >> n >> m;
    if ((m - 1) > (n - m)) {
      out << max(m - 1, (long long int)1);
    } else if ((n - m) > (m - 1)) {
      out << min(m + 1, (long long int)1000000000);
    } else {
      out << max(m - 1, (long long int)1);
    }
  }
};
int main() {
  BSimpleGame solver;
  std::ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}
