r%(a:s)|[(n,t)]<-reads s=last(r+n:[r*n|a<'+'])%t r%_=r m@main=getLine>>=print.(0%).('+':)>>m