#include int main() { int a,b,rep; std::cin >> a >> b; (a < b) ? rep = b-2 : rep = 2000000000-a; std::cout << rep << std::endl; }