#include using namespace std; const int MAX = (int)2e9; int main() { int A, B; scanf("%d %d", &A, &B); if (A > B) { cout << MAX - A << endl; } else { cout << B - A << endl; } return 0; }