using System;
using System.Linq;
class Program
{
	static void Main(string[] args)
	{
		int maxNumber = int.Parse(Console.ReadLine());
        int shouldNonZeroCount = int.Parse(Console.ReadLine());
        int numberCount = 0;
      
        for (int i = 1; i <= maxNumber; i++) {
          int number = i;
          int nonZeroCount = 1;
          while (true) {
            if (number < 10) break;
            if (number % 10 > 0) {
              nonZeroCount++;
            }
            number /= 10;
          }
          if (shouldNonZeroCount == nonZeroCount) {
            numberCount++;
          }
        }
      
        Console.WriteLine(numberCount);
    }
}