using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp6
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var K = Readint();
            var dpt1=Enumerable.Repeat(0, s.Length).Select(x => Enumerable.Repeat(0, K + 1).ToArray()).ToArray();
            var dpt2 = Enumerable.Repeat(0, s.Length).Select(x => Enumerable.Repeat(0, K + 1).ToArray()).ToArray();

            dpt1[0][1] = int.Parse(s[0].ToString()) - 1;
            dpt2[0][1] = 1;
            dpt1[0][0] = 1;

            foreach (var i in Enumerable.Range(1,s.Length-1))
            {
                var current = int.Parse(s[i].ToString());
                dpt1[i][0]=1;
                for(int j=1; j<=K;j++)
                {
                    if (current == 0)
                    {
                        dpt1[i][j] += dpt1[i - 1][j];
                        dpt2[i][j] += dpt2[i - 1][j];
                        dpt1[i][j] += dpt1[i - 1][j - 1] * 9;

                    }
                    else
                    {

                        dpt1[i][j] += dpt1[i - 1][j];
                        dpt2[i][j] += dpt2[i - 1][j - 1];
                        dpt1[i][j] += dpt1[i - 1][j - 1] * 9;

                        dpt1[i][j] += dpt2[i - 1][j];
                        dpt1[i][j] += dpt2[i - 1][j - 1] * (current-1  );
                    }

                }
            }


            Console.WriteLine(dpt1[s.Length-1][K] + dpt2[s.Length-1][K]);
            Console.ReadLine();
  
        }

        static List<int> Readints()
        {
            return  Console.ReadLine().Split(' ').Select(x =>x.ToInt()).ToList();
        }
        static int Readint()
        {
            return Console.ReadLine().ToInt();
        }
        static void Read2int(out int a,out int b)
        {
            var ints = Readints();
            a = ints[0];
            b = ints[1];
        }    
        static int Max(int a,int b)
        {
            return a > b ? a : b;
        }
        



    }

    static  class extensions
    {
        public static int ToInt(this string s)
        {
            return int.Parse(s);
        }

        public static string LJoin<T>(this IEnumerable<T> list)
        {
            return string.Join(" ",list);
        }


    } 


}
