cswork / OAOpen practice workspace

IBMOA #48

Max Subjects Number

Estimated EasyJudge-ready

Topics (AI-labelled)Greedy

In subject i you have already answered answered[i] questions correctly, and you pass once you reach needed[i]. You can answer q more questions correctly in total; find the maximum number of subjects you can pass. Subjects already passed need no extra answers.

Input

The first line contains n q, the second line contains answered, and the third line contains needed. 1≤n≤100000, 0≤elements of both arrays≤10^9. On this site 0≤q≤10^14.

Output

Output one integer, the answer.

Example 1

Input:

3 100
24 27 0
51 52 100

Output:

2

Example 2

Input:

3 200
24 27 0
51 52 100

Output:

3

Example 3

Input:

2 0
5 0
1 1

Output:

1

Example notes

The examples give 2, 3 and 1 respectively.

Editorial

Loading solution…