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