import numpy as np


def main():
    n = [int(x) for x in input()]
    K = int(input())
    dp = np.zeros((len(n)+1, 2, K+1), dtype=int)

    dp[0, 0, 0] = 1

    for i in range(len(n)):
        for k in range(0, K+1):
            for smaller in [0, 1]:
                # use 0
                dp[i+1, 1, k] += dp[i, smaller, k]
                # use 1~9
                r = 9 if smaller == 1 else n[i]
                for x in range(1, r+1):
                    # print(i+1, int(smaller==1 or x <n[i]), k+1, x)
                    if k+1 <= K:
                        dp[i+1, int(smaller == 1 or x < n[i]), k+1] += dp[i, smaller, k]
    print(dp[len(n), 0, K] + dp[len(n), 1, K])


if __name__ == '__main__':
    main()