#include using namespace std; int main() { int n,k; cin >> n >> k; cout << ((k+1 == n+1)?k-1:k+1) << endl; }