nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]

n = int(input());
k = int(input());
ns = str(n);

ans = 0;
for m in range(k,len(ns)) :
	ans += cmb(m-1,k-1)*9**k;

print(ans);

if k == 1 :
	ans += int(ns[0]);
elif k == 2 :
	for i in range(1,len(ns)) :
		ans += int(ns[0]) * int(ns[i]) + (int(ns[i])-1)*9;
elif k == 3 :
	for i in range(1,len(ns)) :
		for j in range(1,len(ns)) :
			if not i == j :
				ans += int(ns[0]) * int(ns[i])* int(ns[j])+ (int(ns[i])-1)*9*9;

print(ans);