use bigrat;print+(bnok$,1e-3*<>%($,=0+<>))%1e9