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