import sys
from io import StringIO
import unittest
from itertools import combinations

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


    a=list(range(0, 100))
    t=0

    if k==3:
        xx = combinations(a, k)
        for p in xx:
            if n<(10**p[0]+10**p[1]+10**p[2]):
                continue
            elif n>=(10**p[0]*9+10**p[1]*9+10**p[2]*9):
                t+=9*9*9
            else:
                for i in range(1,10):
                    for j in range(1,10):
                        for k in range(1,10):
                            if n>=(10**p[0]*i+10**p[1]*j+10**p[2]*k):
                                t+=1
    elif k==2:
        xx = combinations(a, k)
        for p in xx:
            if n<(10**p[0]+10**p[1]):
                continue
            elif n>=(10**p[0]*9+10**p[1]*9):
                t+=9*9
            else:
                for i in range(1,10):
                    for j in range(1,10):
                            if n>=(10**p[0]*i+10**p[1]*j):
                                t+=1
    elif k==1:
        xx = combinations(a, k)
        for p in xx:
            if n<(10**p[0]):
                continue
            elif n>=(10**p[0]*9):
                t+=9
            else:
                for i in range(1,10):
                    for j in range(1,10):
                            if n>=(10**p[0]*i):
                                t+=1


    print(t)

    return

resolve()