#!python3.4
# -*- coding: utf-8 -*-
# abc154/abc154_e
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2s()
    K = i2n()
    res = AEZ(N, K, 0)
    print(res)
    return

def AEZ(N, K, res):
    if K == 0:
        return 1
    N_len = len(N)
    under_d_sum = C(N_len - 1, K) * 9**K
    head = int(N[0])
    #print(N, K, res, under_d_sum, head)
    res = res + under_d_sum + (head-1) * AEZ('9'*(len(N)-1), K-1, res) + AEZ(N[1:], K-1, res)
    return res


def C(n,m):
    if n < m:
        return 0
    if n <= 0:
        return 0
    num = 1
    for i in range(m):
        num *= (n-i)
    if m == 3:
        m = 6
    return num // m

main()
