a, b, c, d, e = map(int, input().split()) num = b - c now = d 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)