package main

import (
	"fmt"
	"strconv"
)

func main() {
	var N, K int64
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d", &K)

	var count int64
	for i := int64(1); i <= N; i++ {
		str := strconv.FormatInt(i, 10)
		var cnt int64
		for _, b := range []byte(str) {
			if b != '0' {
				cnt++
			}
			if cnt > K {
				break
			}
		}
		if cnt == K {
			count++
		}
	}

	fmt.Println(count)
}
