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

namespace CSharpSample01
{


	class Program
	{
		static void Main(string[] args)
		{
			var N = double.Parse(Console.ReadLine());
			var K = int.Parse(Console.ReadLine());

			var answer = 0;
			for(double i = 1; i <= N; i++)
			{
				var notZero = i.ToString().Count(x => x != '0');
				if (notZero == K)
					answer++;
			}

			Console.WriteLine(answer);
		}


	}
}