#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
string S,T,U;
ll K;
string n;
ll N[101];
ll ans;
ll M;
ll dp[105][101];
ll cnt;



int main(){
    cin >> n>>K;
    ll a = n.size();
    for (int i=0;i<a;i++){
        N[i] = n[i] -'0';
    }
    cnt = 0;
    for(int i=0;i<a;i++){
        dp[i][0] = 1;
        for(int j=0;j<=cnt;j++){
            if(cnt<=j){
               dp[i+1][j+1] = dp[i][j+1] +N[i]+(dp[i][j]-1)*9;
            } else {
                dp[i+1][j+1] = dp[i][j+1] + dp[i][j]*9;
            }
        }
        if(N[i]!=0){
            cnt++;
        }
        
    }
    cout << dp[a][K] << endl;