#!/usr/bin/env python3
# -*- coding: UTF-8 -*-

n=input()
x=len(n)
k=int(input())
l=[int(i) for i in n]
dp1=[[0]*(k+2) for i in range(x+1)]
dp2=[[0]*(k+2) for i in range(x+1)]
dp2[0][0]=1
dp2[1][0]=1
dp2[1][1]=l[0]-1
for i in range(1,k+1):
    dp1[i][i]=1
for i in range(k,x+1):
    dp1[i][k]=1
for i in range(2,x+1):
    for j in range(k+1):
        if j==0:
            dp2[i][j]=1
        elif j<=i:
            dp2[i][j]+=max(0,l[i-1]-1)
            dp2[i][j]+=((dp2[i-1][j])+(dp2[i-1][j-1]*9))
            #print(i,j,dp2[i-1][j],dp2[i-1][j-1]*9)
print(dp1[x][k]+dp2[x][k])