t = int(input()) x, a = map(int, input().split()) y, b = map(int, input().split()) ans = y*10**7 for i in range(10**7+1): if t < 0 and b*i < -t: continue ans = min(ans, i*y+(t+b*i)//a*x+(t+b*i)%a) print(ans)