# from scipy.misc import comb
#import numpy as np
#import math
N = int(input()
K = int(input()

def count_0(range_value, zero_count):
    k = 0

    for i in range(range_value):
        if str(i).count("0") == zero_count:
            k+=1

    return k


print(count_0(N, K))