#B3848. Ming's Spending Spree

    ID: 11505 Type: Default 1000ms 256MiB

Ming's Spending Spree

Ming's Spending Spree

Little Ming is known for his unplanned spending. Having just received his pocket money, he immediately heads to the mall and spends it all.

His rule is simple: Whenever he sees an item, if he can afford it, he buys it immediately before moving on; otherwise, he skips it. In other words, if his current money m satisfies the condition $$ m \ge p $$ (where p is the price of the item), he will purchase the item and deduct its price from his money.

Your task is to calculate the total number of items Ming purchases during his shopping trip.

inputFormat

The input consists of two lines:

  • The first line contains two integers n and m where n is the number of items and m is the initial amount of money Ming has.
  • The second line contains n integers representing the prices of the items in the order that Ming encounters them.

outputFormat

Output a single integer representing the total number of items Ming buys.

sample

5 10
3 5 3 2 2
3