#!/usr/bin/python3
# -*- coding: utf-8 -*-
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)]
mozi = input()
n = int(mozi)
k = int(input())
keta = len(mozi)
total = 0
for i in range(k, keta):
    total += (9 ** k) * cmb(i - 1, k - 1)
for i in range(0, keta - k):
    x = int(mozi[i])
    if x > 1:
        total += (x - 1) * (9 ** (k - 1)) * cmb(keta - 1 - i, k - 1)
    else:
        x += 1 
print(total)