#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

//static const MAXIN=101;

int main(){

  string s;
  cin >> s;
  
  //cout << s.length() << endl;
  
  int k;
  cin >> k;
  int c[101][4] = {0};

  int maxn = s.length();
  for (int i=1; i<=maxn;i++){
    c[i][1]=9*(i-1)+s[maxn-i];
    c[i][2]=9*9*(i-1)*(i-2)/2 + s[maxn-i]*c[i-1][1];
    c[i][3]=9*9*9*(i-1)*(i-2)*(i-3)/6 +s[maxn-i]*s[i-1][2];
  }

  cout << c[maxn][k] << endl;

  return 0;
}