import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	K = II()

	def comb(n, r):
		return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
	digits = len(str(N))
	ans = 0
	if(digits < K):
		print(0)
	else:
		for i in range(digits-1, K-1, -1):
			ans += comb(i-1,K-1) * (9**K)
		for i in range(0,K):
			a = int(str(N)[i])
			if(i==0 and a!=0):
				ans += comb(digits-i-1,K-i-1) * (9**(K-1-i)) * (a-1)
			elif(a!=0):
				ans += comb(digits-i-1,K-i-1) * (9**(K-1-i)) * (a-1)
				ans += comb(digits-i-1,K-i) * (9**(K-i))
		cnt = 0
		for s in str(N):
			if(s!='0'):cnt+=1
		if(cnt==K):ans+=1
		if(K<digits):ans+=1
		print(ans)


main()