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