#include using namespace std; int a, b; int main() { cin >> a >> b; if(a > b) cout << 1999999999 - b << endl; else cout << b - 2 << endl; return 0; }