cswork / OAOpen practice workspace

AmazonOA #93

Quiz Subjects — findMaximumNum

Estimated EasyJudge-ready

Topics (AI-labelled)GreedyIn-place Arrays

For subject i, answered[i] questions have already been answered, and passing requires at least needed[i]. You can answer at most q more questions, distributed freely; find the maximum number of subjects you can pass.

Input

The first line contains n q (1≤n≤100000, 0≤q≤10⁹), the second line contains answered, and the third line contains needed, all 0..10⁹.

Output

Output a single integer answer.

Example 1

Input:

3 100
24 27 0
51 52 100

Output:

2

Example 2

Input:

2 0
5 5
1 9

Output:

1

Example 3

Input:

2 5
0 0
2 3

Output:

2

Example notes

Example 1: adding 25 and 27 questions passes two subjects, and the remaining 48 is not enough for the third. Example 2: the first subject is already passed, so with a budget of 0 you still pass 1 subject. Example 3: adding 2 and 3 uses up the budget exactly, and two subjects pass.

Editorial

Loading solution…