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