#include using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int A, B; cin >> A >> B; if (A < B) { cout << B - 2 << '\n'; } else { cout << 2000000000 - A << '\n'; } return 0; }