import sys input = sys.stdin.readline from collections import * A, B, C, D, E = map(int, input().split()) now = D ans = 0 for i in range(A*(B-C)): ans += now if now%10==0 and E<=now: now = now-E print(ans)