n,m=map(int,input().split())
if(n==m and n==1):
print(n)
elif(m-1>=n-m):
print(m-1)
else:
print(m+1)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector < ll > vl;
typedef set < ll > setl;
#define FOR(i, n) for(ll i = 1; i <= n; i++)
#define FORI(i, n) for(ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define forr(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define sync \
ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define arr(a,n) for(ll i=1;i<=n;i++) cout<<a[i]<<" "; cout << "\n";
#define vecc(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout << "\n";
#define COUT(n, a) cout<< fixed << setprecision(a) << n<<endl
int main(){
sync;
int t = 1;
//cin >> t;
while(t--){
int n, m, k;
cin >> n >> m;
k = n / 2;
if(n == 1 && m == 1)cout << 1;
else if(k < m)cout<< m - 1;
else cout << m + 1;
}
}
264A - Escape from Stones | 1506A - Strange Table |
456A - Laptops | 855B - Marvolo Gaunt's Ring |
1454A - Special Permutation | 1359A - Berland Poker |
459A - Pashmak and Garden | 1327B - Princesses and Princes |
1450F - The Struggling Contestant | 1399B - Gifts Fixing |
1138A - Sushi for Two | 982C - Cut 'em all |
931A - Friends Meeting | 1594A - Consecutive Sum Riddle |
1466A - Bovine Dilemma | 454A - Little Pony and Crystal Mine |
2A - Winner | 1622B - Berland Music |
1139B - Chocolates | 1371A - Magical Sticks |
1253A - Single Push | 706B - Interesting drink |
1265A - Beautiful String | 214A - System of Equations |
287A - IQ Test | 1108A - Two distinct points |
1064A - Make a triangle | 1245C - Constanze's Machine |
1005A - Tanya and Stairways | 1663F - In Every Generation |