fun main(args:Array<String>?): Unit {
    while(true) {
        val (a, b, c, d, e) = readLine()!!.trim().split(' ').map(String::toInt)
        if (a == 0) return
        val (na, nb, nc) = readLine()!!.trim().split(' ').map(String::toInt)
        val straight = na * a + nb * b + nc * c
        if (nc >= d) {
            println(nc * e + na * a + nb * b)
        } else if (nb + nc >= d) {
            if (d * e < nc * c + (d - nc) * b) println(d * e + na * a + (nb + nc - d) * b)
            else println(straight)
        } else if (na + nb + nc >= d) {
            if (d * e < nc * c + nb * b + (d - nc - nb) * a) println(d * e + (na + nb + nc - d) * a)
            else println(straight)
        } else if (d * e < straight) {
            println(d * e)
        } else {
            println(straight)
        }
    }
}
