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