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