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