#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring> 
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
#define ll long long 
const ll MOD=1e9+7LL;
const int INF=2e9;
string S;
int K;
ll combi(ll N, int count)
{
	if (count==1) return N*9ll;
	if (count==2) return 81ll*N*(N-1)/2;
	if (count==3) return 729ll*N*(N-1)*(N-2)/6;
	else return 0ll;
}
ll dfs(int idx, int k, bool smaller)
{
	if (k==0) return 1ll; 
	if (smaller) return combi((ll)S.size()-idx, k);
	if (idx==S.size())
	{
		if (k==0) return 1ll;
		else return 0ll;
	}
	if (S[idx]=='0') return dfs(idx+1, k, false);
	ll zero_count = dfs(idx+1, k, true);
	ll between_count = ll(S[idx] - '1') * dfs(idx+1, k-1, true);
	ll icchi_count = dfs(idx+1, k-1, false);
	return zero_count+between_count+icchi_count
}
int main()
{
	cin.sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0); 
	cin>>S>>K;
	cout<<dfs(0,K,false)<<endl;
	return 0;
}