def solve():
    N = int(input())
    K = int(input())
    num = []
    dfs(0,0,num,N,K)
    print(len(num))

def dfs(now,cnt,lst,N,K):
    if now > N:
        return
    
    if cnt == K:
        lst.append(now)
    
    for i in range(10):
        next = now * 10 + i
        if i == 0:
            if now == 0:
                continue
            dfs(next,cnt,lst,N,K)
        else:
            dfs(next,cnt+1,lst,N,K)

if __name__ == '__main__':
    solve()