using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

namespace _200523
{
    public class Solve
    {
        public static void Main(string[] args)
        {
            (new Solve())._E();
        }

        string n;
        int len;
        int k;
        long ans = 0;
        void _E()
        {
            n = Ex.Read;
            len = n.Length;
            k = Ex.ReadInt;

            dfs(0, 0, 1, true);

            ans.Cw();
        }

        void dfs(int i, int now_k, long cou, bool b)
        {
            if (now_k > k)
            {
                return;
            }
            if (i >= len)
            {
                if (now_k == k)
                {
                    ans += cou;
                }
                return;
            }

            // 0
            dfs(i + 1, now_k, cou, false);

            // 1-9
            if (b)
            {

                int max = n[i] - '0';
                if (max - 1 > 0)
                    dfs(i + 1, now_k + 1, cou * (max - 1), false);
                if (max > 0)
                    dfs(i + 1, now_k + 1, cou, true);
            }
            else
            {
                dfs(i + 1, now_k + 1, cou * 9, false);
            }
        }
    }
    public static class Ex
    {
        public static void Cw(this object s) { Console.WriteLine(s); }


        static long Gcd(long m, long n) { if (n == 0) return m; return Gcd(n, m % n); }
        public static List<string> FastSort(this List<string> s) { s.Sort(StringComparer.Ordinal); return s.ToList(); }
        public static void yesno(this bool b) { (b ? "yes" : "no").Cw(); }
        public static void YesNo(this bool b) { (b ? "Yes" : "No").Cw(); }
        public static void YESNO(this bool b) { (b ? "YES" : "NO").Cw(); }

        public static string Read { get { return Console.ReadLine().Trim(); } }
        public static int ReadInt { get { return int.Parse(Read); } }
        public static long ReadLong { get { return long.Parse(Read); } }
        public static double ReadDouble { get { return double.Parse(Read); } }
        public static string[] ReadArray() { return Read.Split(' '); }
        public static int[] ReadIntArray() { return Read.Split(' ').Select(int.Parse).ToArray(); }
        public static long[] ReadLongArray() { return Read.Split(' ').Select(long.Parse).ToArray(); }
        public static string[] ReadArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public static int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public static long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}
