t = int(input()) x,a = map(int,input().split()) y,b = map(int,input().split()) ans = 10**10 for i in range(10**7+5): now = a*i dif = max(now-t,0) j = (dif+b-1)//b # print(i,now,dif,j,now-j*b) now -= j*b ans = min(ans,i*x+j*y+t-now) print(ans)