def main():
    N = int(input())
    K = int(input())
    start = 1
    if K == 2:
        start = 11
    elif K==3:
        start=111
    count = 0
    for i in range(start,N+1):
        tmp = str(i)
        if (len(tmp) - tmp.count('0')) ==K:
            count += 1
    print(count)

if __name__ == '__main__':
    main()