def f(t): v = (t + B - 1)//B * Y t -= (t + B - 1)//B * B t = abs(t) v += t//A * X + t - t//A * A return v T = int(input()) X, A = map(int, input().split()) Y, B = map(int, input().split()) ans = 10 ** 18 if T >= 0: ans = T//A * X + T - T//A * A ans2 = (T + A - 1)//A * X T -= (T + A - 1)//A * A ans2 += f(-T) print(min(ans, ans2)) else: print(f(-T))