#include using namespace std; int main() { int A; int B; const int iLim = 2000000000; cin >> A; cin >> B; if( A > B ) cout << iLim - A << endl; else cout << A - 1 << endl; return 0; }