s=eval(input())*2;n=len(s)/2

def f(i,t,k):

 if k>n-i:return 0

 a=max(t,int(s[i]));i+=1;

 if t:return f(i,9,k)+a*f(i,9,k-1)if k else 1

 else:return(f(i,9,k)+(a-1)*f(i,9,k-1)+f(i,0,k-1)if k else 1)if a else f(i,0,k)

print((f(0,0,int(eval(input())))))
s=eval(input())*2;n=len(s)//2;X=[(0,0)]*4

for j in range(n+1):

 for k in range(3,-1,-1):

  a=int(s[n-j])

  if k>j+1:X[k]=(0,0)

  else:X[k]=(X[k][0]+9*X[k-1][0]if k else 1,(X[k][0]+(a-1)*X[k-1][0]+X[k-1][1]if k else 1)if a else X[k][1])

print((X[int(eval(input()))][1]))
s = eval(input()) * 2
n = len(s) / 2


def f(i, t, k):
    if k > n - i:
        return 0
    a = max(t, int(s[i]))
    i += 1
    if t:
        return f(i, 9, k) + a * f(i, 9, k - 1) if k else 1
    else:
        return (
            (f(i, 9, k) + (a - 1) * f(i, 9, k - 1) + f(i, 0, k - 1) if k else 1)
            if a
            else f(i, 0, k)
        )


print((f(0, 0, int(eval(input())))))

s = eval(input()) * 2
n = len(s) // 2
X = [(0, 0)] * 4
for j in range(n + 1):
    for k in range(3, -1, -1):
        a = int(s[n - j])
        if k > j + 1:
            X[k] = (0, 0)
        else:
            X[k] = (
                X[k][0] + 9 * X[k - 1][0] if k else 1,
                (X[k][0] + (a - 1) * X[k - 1][0] + X[k - 1][1] if k else 1)
                if a
                else X[k][1],
            )
print((X[int(eval(input()))][1]))

-n = len(s) / 2 - - -def f(i, t, k): -    if k > n - i: -        return 0 -    a = max(t, int(s[i])) -    i += 1 -    if t: -        return f(i, 9, k) + a * f(i, 9, k - 1) if k else 1 -    else: -        return ( -            (f(i, 9, k) + (a - 1) * f(i, 9, k - 1) + f(i, 0, k - 1) if k else 1) -            if a -            else f(i, 0, k) -        ) - - -print((f(0, 0, int(eval(input()))))) +n = len(s) // 2 +X = [(0, 0)] * 4 +for j in range(n + 1): +    for k in range(3, -1, -1): +        a = int(s[n - j]) +        if k > j + 1: +            X[k] = (0, 0) +        else: +            X[k] = ( +                X[k][0] + 9 * X[k - 1][0] if k else 1, +                (X[k][0] + (a - 1) * X[k - 1][0] + X[k - 1][1] if k else 1) +                if a +                else X[k][1], +            ) +print((X[int(eval(input()))][1]))