import numpy as np
from sys import stdin
from copy import deepcopy
from functools import reduce
from fractions import gcd
import math
import itertools
from collections import Counter
from itertools import chain  ##list(chain.from_iterable(l)) ##flatten
from heapq import heappush, heappop

"""
N = int(input())
A, B = map(int,input().split())
A = list(map(int,input().split())) ## 横一列
A = [int(input()) for _ in range(N)] ## 縦一列
lst = [list(map(int,input().split())) for i in range(M)] ## 二次元
"""

## コンビネーション計算（mod inv なし）
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result
## ----------------


def ABC154E(n, k):
  ## n is string, k is int
  digit = len(n)
  higher = int(n[0])
  lower = n[1:]
  if digit < k:
    return 0
  elif k == 0:
    return 1
  elif digit == 1:
    return int(n)
  elif n == '9' * digit:
    return cmb(digit, k) * 9 ** k
  else:
    var0 = ABC154E('9' * (digit - 1), k)
    var1 = (higher - 1) * ABC154E('9' * (digit - 1), k - 1) if digit >= 2 else 0
    varn = ABC154E(lower, k - 1) if digit >= 1 else 0
    return var0 + var1 + varn


N = input()
K = int(input())

ans = ABC154E(N, K)
print(ans)