Mock Competition Marketing

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

MOLOCO is a company that matches advertisers with potential users using their high-performance ad platform.

Whenever the application has available space for ads, the app requests the AdExchange platform to determine which ad to show. Then, the AdExchange holds an auction, in which bidders like MOLOCO bid for the opportunity to show their advertisement.

RUN wants to advertise its 2020 ICPC Mock Competition. They have asked MOLOCO for the advertisement. RUN has a total of KK dollars and wants to display the ad for internal apps used by KAISTians. The ads in those apps are in one of six types, and the bidding price depends only on the type of ad. The first bidder to bid on the ad gets to show their ad.

AdExchange has already determined the costs of the six ad types and the NN auctions it will run today. In the ii-th auction, AdExchange will run an auction for an ad of type c_ic\_iAdExchange never runs two auctions at the same time, more specifically auction i+1i+1 cannot start until after auction ii ends.

MOLOCO will bid during auctions using the following strategy - before the auctions begin, RUN selects a set of ad types. During the ii-th auction, if the ad type for that auction is in RUN's set, and RUN has enough money to bid on an ad of that type, MOLOCO will submit a bid. Otherwise, they will ignore it.

MOLOCO is very fast at bidding, so it will always be the first bidder if it bids on the ad. Determine the maximum number of ads they can bid on if RUN selects the set of ad types optimally.

입력

The first line contains two space-separated integers NN, KK. (1N100,000,0K1091 \le N \le 100\\,000, 0 \le K \le 10^9)

The next line contains 6 integers b_1,b_2,,b_6b\_1, b\_2, \ldots, b\_6. b_ib\_i indicates the cost for ad type ii. (1b_i1091 \le b\_i \le 10^9)

The next line contains NN integers c_1,c_2,,c_Nc\_1, c\_2, \ldots, c\_N. c_ic\_i indicates the ad type of the ii-th auction. (1c_i61 \le c\_i \le 6)

출력

Print the maximum number of ads they can bid on.