using System;
using System.Linq;

public class AtCoder_154_E
{
    public static void Main()
    {
        //var exStdIn = new System.IO.StreamReader("input.txt");
        //System.Console.SetIn(exStdIn);

        char[] n = Console.ReadLine().ToCharArray();
        int k= int.Parse(Console.ReadLine());

        long[] pow = new long[] {1, 9, 9 * 9, 9 * 9 * 9};

        if (k > n.Length)
        {
            Console.WriteLine("0");
            return;
        }

        long ans = 0;
        for (int i = 0; i < k; i++)
        {
            int left = int.Parse(n[i].ToString());
            if (left == 0)
            {
                continue;
            }
            if (i < n.Length - 1)
            {
                // 一番大きい暗いを選ばない
                ans += pow[k - i] * nCm(n.Length - i - 1, k - i);
            }
            if (left > 1)
            {
                if (i == k - 1)
                {
                    ans += (left - 1);
                }
                else
                {
                    ans += (left - 1) * pow[k - i - 1] * nCm(n.Length - i - 1, k - i - 1);
                }
            }
        }
        ans++;

        Console.WriteLine(ans);
    }
    // Copyright (C) 2013 sz-x638 All rights reserved.
    // http://zweihander638.blog.fc2.com
    public static long nCm(int n, int m)
    {
        if (m == 0) return 1;
        if (n == 0) return 0;
        return n * nCm(n - 1, m - 1) / m;
    }
}
