fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5.  
  6. void solve() {
  7. ll n, m;
  8. ll a = 0;
  9. cin >> n >> m;
  10.  
  11. if (n == 1) {
  12. cout << "1";
  13. return;
  14. }
  15.  
  16. if (m <= n / 2) {
  17. a = m + 1;
  18. } else {
  19. a = m - 1;
  20. }
  21.  
  22. cout << a;
  23. }
  24.  
  25. int main() {
  26. ios::sync_with_stdio(false);
  27. cin.tie(nullptr);
  28.  
  29. solve();
  30. return 0;
  31. }
  32.  
Success #stdin #stdout 0s 5320KB
stdin
3 1
stdout
2