#include using namespace std; struct Initializer { Initializer() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(15); } } initializer; int main() { int a, b; cin >> a >> b; cout << (a < b ? b - 2 : 1999999999 - b) << endl; }