a;main(b){a=scanf("%d%d",&a,&b)&printf("%d",a=a>b?2e9-b-1:b-2);}