import math
def comb(n,k):
  if n==k and n==0:
    return 1
  if n<=0 or k<0 or n<k:
    return 0
  return math.factorial(n)/(math.factorial(k) * math.factorial(n-k))


N=int(input())
K=int(input())
dig = []
n = math.floor(math.log10(N))+1
for i in range(n):
  dig.append(N // 10**(n-i-1))
  N -= dig[i] * 10**(n-i-1)
ans = 0
ans += (comb(n-1,K) * math.floor(9**K))
print(ans)
ans += (dig[0]-1)* ( (comb(n-2,K-1) * math.floor(9**(K-1))) + 9* (comb(n-2,K-2) * math.floor(9**(K-2))) )
print(ans)
if n>1:
  ans += 1* ( (comb(n-2,K-1) * math.floor(9**(K-1))) + (dig[1]-1)* (comb(n-2,K-2) * math.floor(9**(K-2))) )
  print(ans)
  if n>2:
    ans += 1* ( (comb(n-3,K-2) * math.floor(9**(K-2))) + (dig[2])* (comb(n-3,K-3) * math.floor(9**(K-3))) )
    print(ans)
print(int(ans))