package main

import (
	"fmt"
	"math/big"
	"strings"
)

func main() {
	var nStr string
	var k int
	fmt.Scanf("%s", &nStr)
	fmt.Scanf("%d", &k)
	n := big.Int{}
	n.SetString(nStr, 10)
	// fmt.Println(nStr, k)
	counter := 0
	i := big.Int{}
	one := big.Int{}
	one.SetInt64(1)
	for ; i.Cmp(&n) == -1 || i.Cmp(&n) == 0; i.Add(&i, &one) {
		// fmt.Println(i, i.Cmp(&n), n)
		s := i.String()
		zeros := strings.Count(s, "0")
		if len(s)-zeros == k {
			counter++
		}
	}

	fmt.Println(counter)
}

/*
k = 1
9: 1 - 9
k = 2
11 - 99, 1x1 - 9x9
k =3
111 - 999, 1x11 - 9x99, 11x1 - 99x9, 1x1x1 - 9x9x9
10
*/
