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