use std::io::Read;

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let s: Vec<usize> = it.next().unwrap().chars().map(|c| c.to_digit(10).unwrap() as usize).collect();
    let k: usize = it.next().unwrap().parse().unwrap();
    let mut dp = vec![0usize; k + 2];
    let mut sup = 0;
    for &d in s.iter() {
        let mut next = vec![0; k + 2];
        for i in 0..(k + 1) {
            for _ in 1..10 {
                next[i + 1] += dp[i];
            }
            next[i] += dp[i];
        }
        if d > 0 && sup <= k {
            next[sup] += 1;
        }
        if sup == 0 {
            next[sup] += 1;
        }
        if sup > 0 && sup + 1 <= k {
            for _ in 1..d {
                next[sup + 1] += 1;
            }
        }
        if d > 0 {
            sup += 1;
        }
        dp = next;
    }
    let mut ans = dp[k];
    if sup <= k {
        ans += 1;
    }
    println!("{}", ans);
}

fn main() {
    run();
}
