Vending Machine

No attempts yetTime limit1sMemory limit128 MB

Problem

A snack vending machine sells nn kinds of snacks, numbered 11 through nn. A snack of kind ii has price cic_i, and the machine currently holds lil_i snacks of that kind.

The machine is broken. When you buy a snack of kind ii (which is allowed only while at least one snack of kind ii is still in stock), the machine charges you cic_i and then dispenses that snack together with one snack of every kind 1,2,,i11, 2, \ldots, i-1 that still has stock. Kinds among 1,,i11, \ldots, i-1 that are already sold out are simply skipped. Every dispensed snack (the one you paid for and each bonus one) reduces that kind's remaining stock by one.

Starting with kk units of money, you may keep buying snacks in any order, and you do not have to spend all of your money. Determine the maximum possible total value — the sum of the prices cic_i of all snacks you receive, both purchased and bonus — that you can collect without your spending exceeding kk.

Input

The first line contains two integers nn and kk (1n40, 1k64000)(1 \le n \le 40,\ 1 \le k \le 64000) — the number of snack kinds and the amount of money available.

The second line contains nn integers c1,c2,,cnc_1, c_2, \ldots, c_n (1ci40)(1 \le c_i \le 40) — the prices of the snack kinds.

The third line contains nn integers l1,l2,,lnl_1, l_2, \ldots, l_n (0li40)(0 \le l_i \le 40) — how many snacks of each kind the machine currently holds.

Output

Print a single integer: the maximum total value of snacks obtainable while spending at most kk units of money.

Note

In the first example, buy a snack of kind 66 (paying c6=2c_6 = 2): the machine also releases one snack of kinds 1,2,41, 2, 4 and 55 (kind 33 is out of stock and is skipped). Then buy a snack of kind 44 (paying c4=5c_4 = 5): it additionally releases one snack of kind 22. The two purchases cost 2+5=782 + 5 = 7 \le 8 and yield snacks worth 3030 in total.