A, B, C, D, E = map(int, input().split()) n = B - C X = D P = 0 for i in range(1, n+1): if i % 10 == 0 and E <= X: X -= E P += X print(P)