a, b, c, d, e = list(map(int, input().split())) come = b - c buy = come * a sum = 0 if come != 0: x = 0 for i in range(buy): res = 0 if i == 0: res = d else: if i % 10 != 0: res = x elif i % 10 == 0 and e <= x: res = x - e elif i % 10 == 0 and e >= x: res = x x = res sum += res print(sum)