from functools import lru_cache



@lru_cache(None)

def solve(n,k) :

  if n<=9:

    if k==0: return 1

    if k==1: return n

    return 0

  m = n//10

  r = n%10

  return r*solve(m, k-1)+(9-r)*solve(m-1, k-1)+solve(m, k)



N = int(eval(input()))

K = int(eval(input()))

print((solve(N, K)))
from functools import lru_cache



@lru_cache(None)

def solve(n,k) :

  if n<=9:

    if k==0: return 1

    if k==1: return n

    return 0

  if k==0: return 1

  m, r = divmod(n, 10)

  return r*solve(m, k-1)+(9-r)*solve(m-1, k-1)+solve(m, k)



N = int(eval(input()))

K = int(eval(input()))

print((solve(N, K)))
from functools import lru_cache


@lru_cache(None)
def solve(n, k):
    if n <= 9:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    m = n // 10
    r = n % 10
    return r * solve(m, k - 1) + (9 - r) * solve(m - 1, k - 1) + solve(m, k)


N = int(eval(input()))
K = int(eval(input()))
print((solve(N, K)))

from functools import lru_cache


@lru_cache(None)
def solve(n, k):
    if n <= 9:
        if k == 0:
            return 1
        if k == 1:
            return n
        return 0
    if k == 0:
        return 1
    m, r = divmod(n, 10)
    return r * solve(m, k - 1) + (9 - r) * solve(m - 1, k - 1) + solve(m, k)


N = int(eval(input()))
K = int(eval(input()))
print((solve(N, K)))

-    m = n // 10 -    r = n % 10 +    if k == 0: +        return 1 +    m, r = divmod(n, 10)