A,B,C,D,E=map(int,input().split()) B-=C A*=B ANS=0 X=D for i in range(A): ANS+=X if X%10!=0: continue elif E<=X: X-=E print(ANS)