A,B,C,D,E=map(int, input().split());a,j,m=(B-C)*A,D,D for i in range(1,a+1): if i%10:D+=j elif E<=j:a=max(j-E,0);D+=a;j=a else:D+=j print(D-m)