Pressing and Glittering Records

No attempts yetTime limit3sMemory limit128 MB

Problem

A rapper is producing a special vinyl edition of his album. Every record must first be pressed at a pressing plant, and only then coated with glitter at a glitter shop before it is finished.

The rapper has a contract to make exactly kk records. The pressing plant and the glitter shop can each handle only one record per day. Every record must be pressed before it is glittered, but the same record may be both pressed and glittered on a single day. A record that has been pressed but not yet glittered can be stored for as long as needed at no extra cost.

For each of the next nn days you are given that day's pressing cost and glittering cost. Decide on which days to press and on which days to glitter so that all kk records are finished at the minimum possible total cost.

Input

The first line contains two integers nn and kk (1kn5×1051 \le k \le n \le 5 \times 10^5).

The second line contains nn positive integers, each at most 10910^9; the ii-th value is the pressing cost on day ii.

The third line contains nn positive integers, each at most 10910^9; the ii-th value is the glittering cost on day ii.

Output

Print a single integer: the minimum total cost to produce kk glitter-coated records.

Hint

For the sample input, one optimal plan is: press and glitter the first record on day 1; press the second record on day 2 and glitter it on day 4; press the third record on day 3 and glitter it on day 5; press the fourth record on day 6 and glitter it on day 8. The total cost is 32.