a,b,c,d,e=map(int,input().split()) n=b-c f=0 x=d for j in range(n): for i in range(1,a+1): if i<2: f+=d elif i%10!=0: f+=X elif e>x: f+=X else: x=x-e f+=x print(f)