#include int main(){ int a, b; scanf("%d%d",&a,&b); printf("%d\n",b>a?b-2:1999999999-b); return 0; }