Under construction

Still being built. Things may change

Honey Exhibition

Interview

Time limit1sMemory limit1024 MB

Summary
Given three honey prices and three container capacities, assign each container a distinct honey kind to maximize total earnings.
Level

Easy3 of 10

Topics
Brute force, Greedy, Sorting, Implementation
Solved
No attempts yet

Problem

A farmer preparing for a honey exhibition decided to take three kinds of honey: acacia, linden, and sunflower. One kilogram of acacia honey costs A1 leva, one kilogram of linden honey costs A2 leva, and one kilogram of sunflower honey costs A3 leva. He has three empty containers: the first holds B1 kilograms of honey, the second holds B2 kilograms, and the third holds B3 kilograms.

The farmer must fill each container with a different kind of honey so that after selling them he earns as much profit as possible. When filling the containers, different kinds of honey must not be mixed, and no kind of honey may fill more than one container.

Write a program honey that finds the maximum amount the farmer can earn by selling the honey.

Input

The first line of the standard input contains three natural numbers A1, A2, and A3, the prices of one kilogram of honey of the three kinds. The second line of the standard input contains three natural numbers B1, B2, and B3, the kilograms of honey each of the three containers holds. The numbers on both lines are separated by a single space.

Output

On one line of the standard output the program must print one integer, the maximum amount the farmer can earn.

Constraints

  • 0 < A1, A2, A3, B1, B2, B3 ≤ 100 000 000

Examples1

  1. Example 1

    Input
    7 2 9
    10 5 3
    
    Expected output
    131