#![allow(unused_imports)]
use std::io;
use std::cmp;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::f64::consts::PI;
use std::str::FromStr;

type Error = Box<dyn std::error::Error>;

fn read_line() -> String {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf
}

struct Scanner {
    buff: Vec<String>,
    pos: usize,
}


#[allow(dead_code)]
impl Scanner {
    pub fn new() -> Self {
        Scanner {
            buff: Vec::new(),
            pos: 0,
        }
    }

    pub fn next<T: FromStr>(&mut self) -> T {
        while self.buff.len() <= self.pos {
            self.pos = 0;
            self.buff = read_line().split_whitespace().map(|s| s.to_owned()).collect();
        }

        let result = self.buff[self.pos].parse::<T>();
        self.pos += 1;
        result.ok().unwrap()
    }

    pub fn next_line(&mut self) -> String {
        let result  = read_line().trim().to_owned();
        self.buff.clear();
        self.pos = 0;

        result
    }

    pub fn next_vec<T: FromStr>(&mut self) -> Vec<T> {
        self.buff.clear();
        self.pos = 0;
        read_line().trim().split_whitespace().map(|s| s.parse().ok().unwrap()).collect()
    }
    
    pub fn next_line_chars(&mut self) -> Vec<char> {
        let result  = read_line().trim().chars().collect();
        self.buff.clear();
        self.pos = 0;

        result
    }
}

fn func(n: &Vec<char>, idx: usize, k: usize) -> u64 {
    if k==0 {
        return 1;
    }
    if idx >= n.len() {
        return 0;
    }

    let m = n.len();
    let p = (n[idx] as u8 - '0' as u8) as u64;
    let mut tmp = 0;
    if p > 0 {
        tmp += dbg!((p-1) * func2(m-idx, k-1));
        tmp += func(n, idx+1, k-1);
        tmp += func2(m-idx, k);
    } else {
        tmp += func(n, idx+1, k-1);
    }
    
    dbg!(tmp)
}

fn func2(m: usize, k: usize) -> u64 {
    if m < k || m == 0 {
        return 0;
    }
    let mut tmp = 1;

    for _i in 0..k {
        tmp *= 9 as u64;
    }

    for i in 0..k {
        tmp *= (m-i-1) as u64;
    }
    for i in 0..k {
        tmp /= (i+1) as u64;
    }
    dbg!(tmp)
}


fn main() {
    let mut sc = Scanner::new();

    let n: Vec<char> = sc.next_line_chars();
    let k: usize = sc.next();
    let mut m = n.len();

    let mut ans: u64 = 0;


    println!("{}", func(&n, 0, k));
}
