|You have a piece of paper with exactly D positions laid out in a horizontal row. Each position looks like the following:
_ |_| |_|There are 7 line segments in each position, and each line segment can hold exactly one match. Matches cannot be placed anywhere except on the line segments.
You are given an integer N containing exactly D digits (with no leading zeroes). Spell out the number using matches on the paper. Each digit must occupy a single position. The following diagram shows how each digit should be formed:
_ _ _ _ _ _ _ _ 0 - | | 1 - | 2 - _| 3 - _| 4 - |_| 5 - |_ 6 - |_ 7 - | 8 - |_| 9 - |_| |_| _| |_ _| | _| |_| | |_| _|After you lay out the initial arrangement, you are allowed to move up to K matches. You cannot discard matches or add new matches. After you make all your moves, the final arrangement must be valid (as described above) and the integer formed by the arrangement must contain the same number of digits as the original integer. Leading zeroes are allowed. Return the number of distinct integers that can be formed in this manner. Note that the original integer counts toward the total because it always obtainable by making 0 moves.
|-||N will be between 1 and 10^18 - 1, inclusive. |
|-||K will be between 1 and 126, inclusive.|