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