Cantine

Every day, the UPF cantine offers a different menu. Customers can purchase any combination of items on the menu. Alice is an open-minded person that likes to mix any kind of food, and she wonders how many different combinations of menu items she can afford.

In order to pay for her meal, Alice has a restaurant ticket with total value TT. There is a chance that Alice does not like any item on the menu, so one possible combination is not buying any menu item at all.

Input

The input consists of several test cases. Each test case starts with a pair of integers T<1000T < 1000 (the value of the restaurant ticket) and P<1000P < 1000 (the number of menu items). The next PP numbers denote the price PiP_i of each menu item ii, satisfying Pi<300P_i < 300.

Output

For each test case, output the total number of affordable combinations.

In the first four examples, Alice can afford any of the 2P2^P combinations.

Problem information

Author: Javier Segovia

Generation: 2026-01-25T13:55:51.889Z

© Jutge.org, 2006–2026.
https://jutge.org