#  --*-coding:utf-8-*--

import math

def f(m, k):
    if k > m:
        return 0

    return math.factorial(m)//(math.factorial(m-k)*math.factorial(k))*(9**k)


def g(N, K):
    M = len(N)
    if M < K:
        return 0

    s = 1
    for k in range(K):
        n = int(N[k])
        s += f(M-k-1, K-k) + (n-1)*f(M-k-1, K-k-1)
        
    return s


N = input()
K = int(input())
print(g(N, K))
