#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)


def comb(n, k):
    if n == 0:
        return 1
    ret = 1
    for i in range(k):
        ret *= (n - i)
        ret //= (i + 1)
    return ret

def solve(S: str, K: int):
    N = len(S)
    if N < K:
        print(0)
        return 0
    ret = comb(N, K) * (9 ** K)
    #print(ret)
    for i in range(min(N, K)):
        h = int(S[i])
        ret -= (9 - h) * comb(N - i - 1, K - i - 1) * (9 ** (K - i - 1))
        ret = max(0, ret)
        #print(h, ret)
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = str(next(tokens)) 
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()
