package main

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

// input scanner
var sc = bufio.NewScanner(os.Stdin)

const (
	initialBufSize = 10e4
	maxBufSize     = 10e6
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInt64() int64 {
	a, _ := strconv.ParseInt(next(), 10, 64)
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

// util
func max(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n > ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func min(l []int) (int, int) {
	idx := 0
	ans := l[idx]
	for i, n := range l {
		if n < ans {
			idx = i
			ans = n
		}
	}
	return idx, ans
}

func combi(n int, k int) int {
	a := 1
	b := 1
	for i := 0; i < k; i++ {
		a *= n - i
		b *= (k - i)
	}
	return a / b
}

func check(s string, k int) bool {
	l := len(s)
	var c int
	for i := 0; i < l; i++ {
		a, _ := strconv.Atoi(s[i : i+1])
		if a != 0 {
			c++
		}
		if c > k {
			return false
		}
	}
	if c == k {
		return true
	}
	return false
}

func run(s string, k int) int {
	l := len(s)
	dp := make([][]int, l)
	dpm := make([][]int, l)
	a := make([]int, l)
	for i := 0; i < l; i++ {
		a[i], _ = strconv.Atoi(s[i : i+1])
		dp[i] = make([]int, 3+1)
		dpm[i] = make([]int, 3+1)
	}
	// init
	for i := 1; i < l; i++ {
		dp[i][0] = 1
	}
	dp[0][1] = a[0]
	dp[0][2] = 0
	dp[0][3] = 0

	for i := 1; i < l; i++ {
		for j := 1; j <= 3; j++ {
			if dp[i-1][j-1] == 0 {
				dp[i][j] = 0
			} else if check(s[0:i], j-1) {
				dp[i][j] = dp[i-1][j] + dp[i-1][j-1]*9 - (9 - a[i])
			} else {
				dp[i][j] = dp[i-1][j] + dp[i-1][j-1]*9
			}
		}
	}
	return dp[l-1][k]
}

// main
func main() {
	buf := make([]byte, initialBufSize)
	sc.Buffer(buf, maxBufSize)
	sc.Split(bufio.ScanWords)
	s := next()
	k := nextInt()
	fmt.Println(run(s, k))
}
