#include int main() { int a, b; scanf("%d %d", &a, &b); if (a > b) printf("%d\n", 2000000000 - b - 1); else printf("%d\n", b - 2); return 0; }