@staticmethod
def c():
    (n, h, a, b, c, d, e) = map(int, sys.stdin.read().split())
    y = np.arange((n + 1))
    x = (((((n * e) - h) - ((d + e) * y)) // (b + e)) + 1)
    np.maximum(x, 0, out=x)
    np.minimum(x, (n - y), out=x)
    print(np.amin(((a * x) + (c * y))))
@staticmethod
def c():
    (n, h, a, b, c, d, e) = map(int, sys.stdin.read().split())
    y = np.arange((n + 1))
    x = (((((n * e) - h) - ((d + e) * y)) // (b + e)) + 1)
    np.maximum(x, 0, out=x)
    np.minimum(x, (n - y), out=x)
    print(np.amin(((a * x) + (c * y))))