PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#QHD0000042. Hiệu sách (Book Shop)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Hiệu sách (Book Shop)

Book Shop

Source: CSES

Version: Phuoc Hung OJ Extended

Problem Statement

A bookshop sells nn distinct books, one copy of each. Book ii costs hih_i and contains sis_i pages. You have at most xx units of money and cannot purchase a book more than once. Determine the maximum total number of pages obtainable within your budget. You may buy no books.

Input

The first line contains nn and xx. The second line contains nn prices hih_i. The third line contains nn page counts sis_i.

Output

Print the maximum number of pages.

Subtasks

The independent scoring groups have the following complete constraints:

  • Subtask 1 (20%): 1≤n≤151\le n\le15, 1≤x≤1001\le x\le100, 1≤hi,si≤10001\le h_i,s_i\le1000.
  • Subtask 2 (30%): 1≤n≤1501\le n\le150, 1≤x≤50001\le x\le5000, 1≤hi,si≤10001\le h_i,s_i\le1000.
  • Subtask 3 (50%): 1≤n≤10001\le n\le1000, 1≤x≤1000001\le x\le100000, 1≤hi,si≤10001\le h_i,s_i\le1000.

Examples

Input

4 10
4 8 5 3
5 12 8 1

Output

13

Explanation

Buy books 1 and 3 at prices 44 and 55. Their total price is 9≤109\le10 and they contain 5+8=135+8=13 pages, which is optimal.