def main():
    n = input()
    k = int(input())

    digits = len(n)
    ans = 1
    for i in range(0,k):
        ans = ans * (digits-i)
    for i in range(1,k+1):
        ans = ans//i
    
    for i in range(k):
        ans *= 9

    minus = 0
    if k == 1:
        minus = 9 - int(n[0])
    elif k == 2:
        b = 9 - int(n[0])
        minus = b*(digits-1)*9+(9-int(n[1]))
    elif k == 3:
        b = 9 - int(n[0])
        minus += b*(digits-1)*(digits-2)*9*9//2
        minus += (9-int(n[1]))*(digits-2)*9
        minus += (9-int(n[2]))

    print(ans-minus)


main()