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