
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using System.Diagnostics;

namespace at_coder
{
#if TEST
    [TestClass]
#endif
    public class abc154_e
    {

#if TEST
        public static void Test_Main()
#else
        public static void Main()
#endif
        {
            string s = Console.ReadLine();
            int k = readint();
            long n = solve(s, k);

            println(n.ToString());
        }

        private static long solve(string s, int k)
        {
            var i = parseS(s);
            return solve(i, k);
        }

        private static long solve(Item i, int k)
        {
            // 全桁 0 の場合を返す
            if (k <= 0)
            {
                return 1;
            }

            // 次の桁を調査する
            long ll = 0;

            int deep = GetDeep(i.Next);

            if (i.A > 0)
            {
                // 0 の場合
                long l2 = C(deep, k);
                for (int j = 0; j < k; j++)
                {
                    l2 *= 9;
                }
                ll += l2;
            }

            // 現在の桁が 0の倍の処理
            if (i.A > 1)
            {
                long deepN = C(deep, k - 1); // 組み合わせの数
                for(int j=0; j < k - 1;j++)
                {
                    deepN = deepN * 9;
                }
                long l3 = deepN * (i.A - 1); // その総数
                ll += l3;
            }

            long l4 = solve(i.Next, k - 1);

            ll += l4;

            return ll;
        }


        static long C(int a, int b)
        {
            long l = 1;
            int d = a;
            for (int i = 0; i < b; i++)
            {
                l = l * d;
                d = d - 1;
            }
            for (int i = 1; i <= b; i++)
            {
                l = l / i;
            }
            return l;
        }

        static int GetDeep(Item i)
        {
            int n = 0;
            while(i != null)
            {
                n++;
                i = i.Next;
            }
            return n;
        }
        

        public static Item parseS(string s)
        {
            Item next = null;
            for(int i=s.Length-1; i >= 0; i--)
            {
                char c = s[i];
                Item a = new Item()
                {
                    A = ((int)c) - ((int)'0'),
                    Next = next
                };

                next = a;
            }

            return next;
        }

        public class Item
        {
            public int A;
            public Item Next;
        }


        private static void println(string s)
        {
            Console.WriteLine(s);
        }

        private static int readint()
        {
            String s = Console.ReadLine();
            return int.Parse(s);
        }

        private static int[] ReadIntArray()
        {
            string[] ss = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            int[] ar = new int[ss.Length];
            for (int i = 0; i < ss.Length; i++)
            {
                ar[i] = int.Parse(ss[i]);
            }
            return ar;
        }

#if TEST
#else
    }
}
#endif
