Time limit 1000/1000/4000/4000 ms. Memory limit 65000/65000/65000/65000 Kb.
Problem description
There are N nests on the tree and ai gold coins in each of them. Michel Jordan noticed that each i-th nest will fall down if there will be bi coins. If he has m gold coins then what is the maximum number of coins he can get by throwing them into the nests?
Input
On the first line there are 2 integer values n and m (1≤n,m≤1000). On the second n integer values ai (0≤ai≤1000), and n integer values on the third bi (ai<bi≤1000).
Output
Write the maximum number of coins that Michel Jordan can get.
Example
| stdin |
stdout |
2 3
1 2
4 6 |
6 |
3 3
1 2 3
4 8 16
|
4 |
Для отправки решений необходимо выполнить вход.
|