using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static long Mod = (long)1e9 + 7;
        static long N, M, Q;
        static long[] a, b, c, d;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var S = ReadLine();
            var N = S.Length;
            var K = Sarray()[0];

            var dp = new long[N, 4, 2];
            var F = 0;
            var T = 1;
            var Ss = S[0] - '0';
            dp[0, 1, F] = Ss - 1;
            dp[0, 1, T] = 1;
            for (var i = 1; i < N; ++i)
            {
                var Sn = S[i] - '0';
                var Sp = S[i - 1] - '0';

                for (var k = 1; k <= 3; ++k)
                {
                    //0に推移する場合
                    dp[i, k, F] += dp[i - 1, k, F];
                    if (0 != Sn)
                        dp[i, k, F] += dp[i - 1, k, T];

                    //0以外に遷移する場合
                    dp[i, k, F] += 9 * dp[i - 1, k - 1, F];
                    dp[i, k, F] += (Sn - 1) * dp[i - 1, k - 1, T];

                    //張り付き
                    if (0 == Sn)
                        dp[i, k, T] = dp[i - 1, k, T];
                    else
                        dp[i, k, T] = dp[i - 1, k - 1, T];
                }
                //前全部0から推移
                dp[i, 1, F] += 9;
            }
            var ans = dp[N - 1, K, F] + dp[N - 1, K, T];
            WriteLine(ans);
        }
    }
}