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