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
Subtask 1 [10%]
All of the digits are the same.
Subtask 2 [90%]
No additional constraints.
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 ).
Comments
could anyone help with batch 2 test case #8? I'm really stuck -- https://dmoj.ca/submission/5946631