#define _USE_MATH_DEFINES #include #define FOR(i,a,b) for(int i = (a); i < (b); ++i) #define REP(i,n) FOR(i,0,n) #define SZ(n) (int)(n).size() #define ALL(n) (n).begin(), (n).end() #define MOD 1000000007 using namespace std; typedef long long LL; typedef vector VI; int main() { LL a, b; cin >> a >> b; if (a < b) cout << b - 1 - 1 << endl; else cout << 2000000000 - b - 1 << endl; return 0; }