#include int main(){int A,B,C;scanf("%d%d",&A,&B);printf("%d",C=A>B?1999999999-B:B-2);return 0;}