from functools import lru_cache
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int,read().split())

@lru_cache(None)
def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret

print(F(N, K)) from functools import lru_cache import sys sys read = sys.stdin.buffer.read read sys.stdin.buffer.read sys.stdin.buffer sys.stdin sys stdin buffer read readline = sys.stdin.buffer.readline readline sys.stdin.buffer.readline sys.stdin.buffer sys.stdin sys stdin buffer readline readlines = sys.stdin.buffer.readlines readlines sys.stdin.buffer.readlines sys.stdin.buffer sys.stdin sys stdin buffer readlines N, K = map(int,read().split()) N map(int,read().split()) map int read().split() ().split () read split K def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret F if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
     N < 10 N 10 if K == 0:
            return 1
         K == 0 K 0 return 1 1 if K == 1:
            return N
         K == 1 K 1 return N N return 0 0 q, r = divmod(N, 10) q divmod(N, 10) divmod N 10 r ret = 0 ret 0 if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
     K >= 1 K 1 ret += F(q, K-1) * r ret F(q, K-1) * r F(q, K-1) F q K-1 K 1 r ret += F(q-1, K-1) * (9-r) ret F(q-1, K-1) * (9-r) F(q-1, K-1) F q-1 q 1 K-1 K 1 9-r 9 r ret += F(q, K) ret F(q, K) F q K return ret ret N N K K @lru_cache(None) F None @lru_cache(None) lru_cache None F print(F(N, K)) print F(N, K) F N K read = sys.stdin.buffer.read sys.stdin.buffer.read read def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret F readline = sys.stdin.buffer.readline sys.stdin.buffer.readline readline N, K = map(int,read().split()) map(int,read().split()) N K = map(int,read().split()) map(int,read().split()) K readlines = sys.stdin.buffer.readlines sys.stdin.buffer.readlines readlines
from functools import lru_cache
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N, K = map(int,read().split())

@lru_cache(None)
def F(N, K):
    if N < 10:
        if K == 0:
            return 1
        if K == 1:
            return N
        return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        ret += F(q, K-1) * r
        ret += F(q-1, K-1) * (9-r)
    ret += F(q, K)
    return ret

print(F(N, K))