atcoder#ABC208E. [ABC208E] Digit Products

[ABC208E] Digit Products

Score : 500500 points

Problem Statement

For how many positive integers at most NN is the product of the digits at most KK?

Constraints

  • 1N10181 \leq N \leq 10^{18}
  • 1K1091 \leq K \leq 10^9
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

NN KK

Output

Print the number of integers satisfying the condition.

13 2
5

Out of the positive integers at most 1313, there are five such that the product of the digits is at most 22: 11, 22, 1010, 1111, and 1212.

100 80
99

Out of the positive integers at most 100100, all but 9999 satisfy the condition.

1000000000000000000 1000000000
841103275147365677

Note that the answer may not fit into a 3232-bit integer.