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