T=int(input()) X,A=map(int,input().split()) Y,B=map(int,input().split()) def calc(na:int): x = A*na t=X*na if x <= T: return (T-x) + t d = x-T nb = (d+B-1)//B t += Y*nb x -= B*nb return t + (T-x) low = 0 high = 10**12 ans = 10**20 while low