Time

12:47:49
23 May 2012
Version for print

The Number which Cuts

   Vasylko wrote a number which is multiple of d on a scrap of paper. His smaller brother Dmytryk cut the number to k parts. Vasylko decided to restore the number, which he wrote. He remembered only number d. But there was a problem. It is possible to make many numbers which are multiple of d.

   How many numbers multiple of d can make Vasylko? He uses all parts when he make a number.


Specifications

   Input

   The first line contains two integers d and k ( k < 9, 1 ≤ d ≤ 100). The parts of the number lie in the next k lines. The number of digits in each part does not exceed 10.

   Output

   Print the amount of different numbers.


Problem information

Time Limit: 1 seconds
Memory Limit: 64 MB
Balls for the passed test: 10
Complexity: 33% 58/87

Example

Example input

5 3
13
85
45

Example output

4


← The Smart Cat Problems The Cost of the K-dominoes →