package main

import (
	"bufio"
	"fmt"
	"os"
	"regexp"
	// "sort"
	"strconv"
	// "strings"
	// "math"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	stdin.Split(bufio.ScanWords)
	var N, K int

	N = nextInt()
	K = nextInt()
	re := regexp.MustCompile(`[1-9]`)
	cnt := 0
	for i := 1; i < N+1; i++ {
		// fmt.Println(len(re.Find([]byte(strconv.Itoa(i)))))
		if len(re.FindAll([]byte(strconv.Itoa(i)), -1)) == K {
			cnt++
		}
	}
	fmt.Println(cnt)

}

func nextInt() int {
	stdin.Scan()
	i, err := strconv.Atoi(stdin.Text())
	if err != nil {
		panic(err)
	}
	return i
}

