

@memo = {}

# 10^n未満で0以外の個数がちょうどkな数の個数
def f(n, k)
  if n == 0
    0
  elsif n == 1
    if k == 1
      9
    elsif k == 0
      1
    else
      0
    end
  elsif k > n
    0
  else
    @memo[[n,k]] ||= f(n - 1, k) + f(n - 1, k - 1) * 9
  end
end

def g(x, k)
  if x.size == 0
    0
  elsif x.size == 1 && k == 0
    1
  elsif x.size == 1 && k == 1
    x[0]
  elsif x.size == 1
    0
  else
    sz = x.size - 1
    y = x[0]
    ans = f(sz, k) * 1
    if y > 0
      ans += f(sz, k - 1) * (y-1) + g(x[1..-1], k - 1)
    end
    ans
  end
end

x = (gets.to_i + 0).to_s.chars.map{|x| x.to_i }
k = gets.to_i
puts g(x, k)