#include <stdio.h>
#pragma warning(disable : 4996)

long KNonZeroDigitedNumbers(N, K)
long K;
long N;
{
	long count = 0;
	for (long i = 0; i <= N; i++) {
		long nonZeroDigits = 0;
		long num = i;
		while (num != 0) {
			if (num % 10 != 0) {
				nonZeroDigits++;
			}
			num /= 10;
		}
		if (nonZeroDigits == K) {
			count++;
		}
	}
	return count;
}

main(void) {
	long N = 0;
	long K = 0;
	if (!scanf("%lli", &N)) {
		printf("something wrong with input");
	}
	if (!scanf("%lli", &K)) {
		printf("something wrong with input");
	}
	printf("%lli\n", KNonZeroDigitedNumbers(N,K));
}