import sys
def combination(a, b):
    if b == 1:
        return a
    if b == 2:
        return (a*(a-1))//2
    if b == 3:
        return (a*(a-1)*(a-2))//6
def main():
    N = input()
    K = int(input())
    ans = 0
    for k in range(K):
        n = N[k:]
        L = len(n)
        s = K-k
        ans += combination(L-1,s)*(9**(s))
        if s-1 > 0:
            ans += (int(N[0])-1)*combination(L-1,s-1)*(9**(s-1))
    ans += int(N[K-1])
    print(int(ans))
if __name__ == "__main__":
    main()
