def floor(x,y): return x//y def ceil(x,y): return (x+y-1)//y def solve(): T=int(input()) X,A=map(int,input().split()) Y,B=map(int,input().split()) if T>0: K0=0 K1=floor(T,Y) else: T_abs=abs(T) K0=ceil(T_abs,B) K1=floor(B,Y)+ceil(T_abs,B) Ans=float("inf") for r in range(K0,K1+1): q,p=divmod(T+r*B,A) Ans=min(Ans, p+q*X+r*Y) return Ans print(solve())