def cmb(a,b):
    if b == 0 :
        ans=1
    else:
        Nu = 1
        Di = 1
        for i in range(b):
            Nu = Nu*(a-i)
            Di = Di*(b-i)
        ans = Nu/Di
    return ans


def f(a,keta,K):
    ans = cmb(keta,K)*9**K
    if K == 1:
        ans += a
    else:
        ans += cmb(keta, K-1)*9**(K-1)*(a-1)
    return ans



def main():
    N = int(input())
    K = int(input())

    ans = 0
    while K>0 and N>0:
        keta = len(str(N))-1
        if keta + 1 < K: break
        if keta == 0:
            if K==1 :ans += N
        a = int(N/(10**(keta)))
        ans += f(a,keta,K)
        N -= a*10**keta
        K -= 1
        print(a,keta,ans)
    print(int(ans))
    return

if __name__=="__main__":
    main()