CSES - Ascending integers

An integer is ascending if each digit is greater than or equal to the preceding digit. For example, the integers 22, 347347 and 2556825568 are ascending.

Your task is to count how many ascending integers of a given length can be formed using a given set of digits.

For example, when the length is 33 and the allowed digits are 11, 22 and 33, the desired answer is 1010, because in this case the valid ascending integers are 111111, 112112, 113113, 122122, 123123, 133133, 222222, 223223, 233233 and 333333.

In a file incnum.py, implement the function count_numbers that takes the length and the allowed digits as parameters. The function should return the number of ascending integers.

The function should be efficient when the length of the integer is in the range 1101 \dots 10.

def count_numbers(length, numbers):
    # TODO

if __name__ == "__main__":
    print(count_numbers(3, "123")) # 10
    print(count_numbers(5, "1")) # 1
    print(count_numbers(2, "137")) # 6
    print(count_numbers(8, "25689")) # 495
    print(count_numbers(1, "0")) # 1
    print(count_numbers(2, "0")) # 0
    print(count_numbers(10, "12")) # 11
    print(count_numbers(10, "123456789")) # 43758

Notice that an ascending integer may not have leading zeros if the length is two or more. For example, 0000 and 012012 are not valid ascending integers, but 00 is an ascending integer.