a,b,c,d,e = map(int,input().split()) p = b-c t = 0 v = d for i in range(1, a+1): if i >= 2: if i % 10 == 0 and e <= v: v -= e t += v print(t * p)