#ACSL2223S1. ACSL2223S1

ACSL2223S1

PROBLEM: Given 3 positive integers, n, b, and s, generate the next n numbers in base b starting with s in the given base. We guarantee that the base will be between 2 and 16 inclusive. We guarantee that s is a valid number in base b. Find all of the digits in the numbers generated and print the number of times, in base 10, that the most frequently found digit occurs.

EXAMPLE: If n=15, b=8, and s=2, the numbers generated are 2, 3, 4, 5, 6, 7, 10, 11, 12, 13,14, 15, 16, 17, 20. The digit that occurs most frequently is 1 which occurs 9 times so the output would be 9.

INPUT: There will be three values representing how many numbers to generate, the base to be used between 2 and 16 inclusive, and the starting value in the base given that will be no more than 16 digits long. We guarantee that s is a valid number in base b.

OUTPUT: For each set of3 input values, find how many times each digit occurs in the sequence of numbers generated. Then output the number of times the digit that is found the most actually occurs.

SAMPLE INPUT:

15 8 2
25 2 1111011
20 12 9AB
10 16 ABCDEF
1000 2 1

SAMPLE OUTPUT:

9
105
14
10
4938