## BPC 1 J4 - Assignment of the Year

View as PDF

Points: 10 (partial)
Time limit: 1.5s
Memory limit: 512M

Authors:
Problem type

This year at Spirit of Math Schools, you have been assigned to find the number of unique numbers between and (inclusive) you can create using a list of digits. You may add or concatenate digits. Their order must be maintained, and every digit must be used. Output the number of unique values you can create between and .

#### Constraints

All of the digits are the same.

#### Input Specification

The first line contains two integers, and .

The next line contains a string of digits (numbers between and ).

#### Output Specification

Output a single line containing an integer, the number of unique values that can be created.

#### Sample Input

4 100
1996

#### Sample Output

2

#### Explanation for Sample

There are 8 possible combinations of operations:

Only two of these are between and ( and ).