s = map(int, list(raw_input()))
k = int(raw_input())
seen = {}


2
351
def dfs(i, k, s, cur, seen, pe = False):
	
	if k < 0: return 0
	if i == len(s):
		#if k == 0: print cur

		return 1 if k == 0 else 0

	if k == 0:
		#print cur + [0] * (len(s) - i )
		return 1
	if (i, pe, k) in seen:
		return seen[(i,pe,k)]
	r = 0
	q = max(0, (s[i] if pe else 10) -1)
	r+= q * dfs(i + 1, k - 1, s, cur, seen, False)

	#for num in range(1, s[i] if pe else 10):
	#	r += dfs(i + 1, k - 1, s, cur + [num])

	r += dfs(i + 1, k, s, cur + [0], seen, False )
	if s[i] and pe:
		r += dfs(i + 1, k - 1, s, cur , seen, pe)

	seen[(i,pe,k)] = r
	return r
print dfs(0, k, s, [], seen, True)