#!/usr/bin/env python3

def main():
    n = input()
    l = len(n)
    k = int(input())
    dp0 = [0 for j in range(4)]
    dp1 = [0 for j in range(4)]
    dp1[0] = 1
    for i in range(l):
        d = int(n[i])
        if d == 0:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
        else:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
            dp0[0] += dp1[0]
            dp1 = [0] + dp1[0:3]
    print(dp0[k] + dp1[k])

if __name__ == "__main__":
    main() def main():
    n = input()
    l = len(n)
    k = int(input())
    dp0 = [0 for j in range(4)]
    dp1 = [0 for j in range(4)]
    dp1[0] = 1
    for i in range(l):
        d = int(n[i])
        if d == 0:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
        else:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
            dp0[0] += dp1[0]
            dp1 = [0] + dp1[0:3]
    print(dp0[k] + dp1[k]) main n = input() n input() input l = len(n) l len(n) len n k = int(input()) k int(input()) int input() input 0 for j in range(4) for j in range(4) j range(4) range 4 for j in range(4) 0 dp0 = [0 for j in range(4)] dp0 [0 for j in range(4)] 0 for j in range(4) for j in range(4) j range(4) range 4 for j in range(4) 0 dp1 = [0 for j in range(4)] dp1 [0 for j in range(4)] dp1[0] = 1 dp1[0] dp1 0 1 for i in range(l):
        d = int(n[i])
        if d == 0:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
        else:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
            dp0[0] += dp1[0]
            dp1 = [0] + dp1[0:3]
     i range(l) range l d = int(n[i]) d int(n[i]) int n[i] n i if d == 0:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
        else:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
            dp0[0] += dp1[0]
            dp1 = [0] + dp1[0:3]
     d == 0 d 0 for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
         j [3, 2, 1] 3 2 1 dp0[j] += dp0[j - 1] * 9 dp0[j] dp0 j dp0[j - 1] * 9 dp0[j - 1] dp0 j - 1 j 1 9 for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
             j [3, 2, 1] 3 2 1 dp0[j] += dp0[j - 1] * 9 dp0[j] dp0 j dp0[j - 1] * 9 dp0[j - 1] dp0 j - 1 j 1 9 dp0[j] += dp1[j - 1] * max(0, d - 1) dp0[j] dp0 j dp1[j - 1] * max(0, d - 1) dp1[j - 1] dp1 j - 1 j 1 max(0, d - 1) max 0 d - 1 d 1 dp0[j] += dp1[j] dp0[j] dp0 j dp1[j] dp1 j dp0[0] += dp1[0] dp0[0] dp0 0 dp1[0] dp1 0 dp1 = [0] + dp1[0:3] dp1 [0] + dp1[0:3] [0] 0 dp1[0:3] dp1 0:3 0 3 print(dp0[k] + dp1[k]) print dp0[k] + dp1[k] dp0[k] dp0 k dp1[k] dp1 k if __name__ == "__main__":
    main() __name__ == "__main__" __name__ "__main__" main() main def main():
    n = input()
    l = len(n)
    k = int(input())
    dp0 = [0 for j in range(4)]
    dp1 = [0 for j in range(4)]
    dp1[0] = 1
    for i in range(l):
        d = int(n[i])
        if d == 0:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
        else:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
            dp0[0] += dp1[0]
            dp1 = [0] + dp1[0:3]
    print(dp0[k] + dp1[k]) def main():
    n = input()
    l = len(n)
    k = int(input())
    dp0 = [0 for j in range(4)]
    dp1 = [0 for j in range(4)]
    dp1[0] = 1
    for i in range(l):
        d = int(n[i])
        if d == 0:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
        else:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
            dp0[0] += dp1[0]
            dp1 = [0] + dp1[0:3]
    print(dp0[k] + dp1[k]) main
#!/usr/bin/env python3

def main():
    n = input()
    l = len(n)
    k = int(input())
    dp0 = [0 for j in range(4)]
    dp1 = [0 for j in range(4)]
    dp1[0] = 1
    for i in range(l):
        d = int(n[i])
        if d == 0:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
        else:
            for j in [3, 2, 1]:
                dp0[j] += dp0[j - 1] * 9
                dp0[j] += dp1[j - 1] * max(0, d - 1)
                dp0[j] += dp1[j]
            dp0[0] += dp1[0]
            dp1 = [0] + dp1[0:3]
    print(dp0[k] + dp1[k])

if __name__ == "__main__":
    main()
