package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string { sc.Scan(); return sc.Text() }
func scanInt() int { a,_ := strconv.Atoi(scanString()); return a }
func scanInt64() int64 { a,_ := strconv.ParseInt(scanString(),10,64); return a }
func scanFloat64() float64 { a,_ := strconv.ParseFloat(scanString(),64); return a }

func scanInts(n int) []int {
	res := make([]int, n); for i := 0; i < n; i++ { res[i] = scanInt() }; return res
}

func abs(a int) int { if a<0 { return -a }; return a }
func min(a,b int) int { if a<b { return a }; return b }
func max(a,b int) int { if a>b { return a }; return b }

//•*¨*•.¸¸♪Main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1000000)

	n := scanString()
	k := scanInt()

	dp := make([][][]int, len(n)+1)

	for i := 0; i < len(n)+1; i++ {
		dp[i] = make([][]int, 2)
		dp[i][0] = make([]int, k+1)
		dp[i][1] = make([]int, k+1)
	}

	dp[0][0][0] = 1
	ans := 0

	for i := 0; i < len(n); i++ {
		num, _ := strconv.Atoi(string(n[i]))
		if num == 0 {
			for j := 0; j < k; j++ {
					dp[i+1][0][j] = dp[i][0][j]
			}
		} else {
			for j := 0; j < k; j++ {
				dp[i+1][0][j+1] = dp[i][0][j]
			}
		}
		
		dp[i+1][1][0] = 1
		// dp[i+1][1][j+1] = dp[i][1][j]+dp[i][1][j-1]*9+dp[i][0][j]
		for j := 0; j < k; j++ {
			if num != 0 {
				dp[i+1][1][j] += dp[i][0][j]
				dp[i+1][1][j+1] += dp[i][0][j]*(num-1)
			}
			dp[i+1][1][j] += dp[i][1][j]
			dp[i+1][1][j+1] += dp[i][1][j]*9
			// fmt.Println(j,dp[i][1][j])
		}
		
		ans += dp[i+1][0][k] + dp[i+1][1][k]
		// fmt.Println(dp[i+1][0])
		// fmt.Println(dp[i+1][1])
	}

	fmt.Println(ans)
}