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