# -*- coding: utf-8 -*-
#import itertools
#import numpy as np
import math

n = int(input())
k = int(input())
sn = str(n)
l = len(sn) # 10^(l-1) < n < 10^l
ans = 0
z = 0

def combinations_count(n, r):
    x = 1
    for y in range(n-r+1, n+1):
        x *= y
    for z in range(1, r+1):
        x //= z
    return x
    
if k <= l-1:
    ans += combinations_count(l-1, k) * (9 ** k)

    # l桁の整数について
    if k == 1:
        z = int(sn[0])
        
    elif k == 2:
        z = (int(sn[0])-1) * (l-1)*9
        z += int(sn[1])
        z += (l-2) * 9
        
    else:
        z = (int(sn[0])-1) * combinations_count(l-1, 2)*81
        for i in range(l-2):
            z += int(sn[i+1]) * sum(list(map(int, list(sn[i+2:]))))

print(ans + z)
