import sys input = sys.stdin.readline A,B,C,D,E=map(int,input().split()) k=(B-C)*A DP=[D] for i in range(1000): X=DP[-1] if (i+2)%10!=0: DP.append(X) elif E<=X: DP.append(X-E) else: DP.append(X) S=[0] for i in range(1000): S.append(S[-1]+DP[i]) print(S[k])