a,b,c,d,e = map(int,input().split()) ans = 0 x = 0 for i in range(1,(b-c)*a +1): if i == 1: ans += d x = d continue if i % 10 != 0: ans += x continue if i % 10 == 0 and e <= x: ans += x-e x = x-e continue if i % 10 == 0 and e > x: ans += x continue print(ans)