using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            StreamScanner scan = new StreamScanner(System.Console.OpenStandardInput());
            string n = scan.Scan();
            int k = scan.Integer();
            long sum = 0;
            int count = n.Length;
            int gen = Math.Min(k, count-1);
            int zerocount = 0;
            for (int i = 0; i <= gen; i++)
            {
                if (n[i] == '0')
                {
                    zerocount++;
                    continue;
                }
                sum += solve(count - i, k-i+zerocount, n[i] - '0');
            }
            Console.WriteLine(sum);

        }

        static int solve(int n,int k,int saijyoui)
        {
            if (saijyoui == 0)
                return 0;
            switch (k)
            {
                case 0:
                    return 0;
                case 1:
                    return 9 * (n - 1) + saijyoui;
                case 2:
                    if (n == 1)
                        return 0;
                    return (saijyoui - 1) * 9 * (n - 1) + 9 * 9 * (n - 1) * (n - 2) / 2;
                case 3:
                    if (n <= 2)
                        return 0;
                    return (saijyoui - 1) * 9 * 9 * (n - 1) * (n - 2) / 2 + 9 * 9 * 9 * (n-3) * (n - 1) * (n - 2) / 6;
                default:
                    return 0;
            }
        }
    }
    public class StreamScanner
    {
        public StreamScanner(Stream stream) { str = stream; }
        private readonly Stream str;
        private readonly byte[] buf = new byte[1024];
        private int len, ptr;
        public bool isEof = false;
        public bool IsEndOfStream { get { return isEof; } }
        private byte read()
        {
            if (isEof) throw new EndOfStreamException();
            if (ptr >= len)
            {
                ptr = 0;
                if ((len = str.Read(buf, 0, 1024)) <= 0)
                {
                    isEof = true;
                    return 0;
                }
            }
            return buf[ptr++];
        }
        public char Char()
        {
            byte b = 0;
            do b = read();
            while (b < 33 || 126 < b);
            return (char)b;
        }
        public string Scan()
        {
            var sb = new StringBuilder();
            for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
                sb.Append(b);
            return sb.ToString();
        }
        public long Long()
        {
            long ret = 0; byte b = 0; var ng = false;
            do b = read();
            while (b != '-' && (b < '0' || '9' < b));
            if (b == '-') { ng = true; b = read(); }
            for (; true; b = read())
            {
                if (b < '0' || '9' < b)
                    return ng ? -ret : ret;
                else ret = ret * 10 + b - '0';
            }
        }
        public int Integer() { return (int)Long(); }
        public double Double() { return double.Parse(Scan(), CultureInfo.InvariantCulture); }
    }
    public class UnionFind
    {
        public int[] data;

        public UnionFind(int size)
        {
            data = new int[size];
            for (int i = 0; i < size; i++) data[i] = -1;
        }

        public bool Unite(int x, int y)
        {
            x = Root(x);
            y = Root(y);

            if (x != y)
            {
                if (data[y] < data[x])
                {
                    var tmp = y;
                    y = x;
                    x = tmp;
                }
                data[x] += data[y];
                data[y] = x;
            }
            return x != y;
        }

        public bool IsSameGroup(int x, int y)
        {
            return Root(x) == Root(y);
        }

        public int Root(int x)
        {
            return data[x] < 0 ? x : data[x] = Root(data[x]);
        }
    }
}
