#include <bits/stdc++.h>
using namespace std;
class TaskB {
 public:
  void solve(istream &in, ostream &out) {
    int n, m;
    in >> n >> m;
    int a = min(n, m + 1);
    int b = max(1, m - 1);
    if (m == 1)
      out << min(2, n);
    else if (n - a == b - 1)
      out << b;
    else
      out << (n - a > b - 1 ? a : b);
  }
};
int main() {
  std::ios_base::sync_with_stdio(false);
  TaskB solver;
  std::istream &in(std::cin);
  std::ostream &out(std::cout);
  in.tie(0);
  out << std::fixed;
  out.precision(20);
  solver.solve(in, out);
  return 0;
}
