#include <bits/stdc++.h>
using namespace std;
using vi = vector<long long>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
long long k, x, y;
int main() {
  long long ans = 0;
  string n;
  cin >> n >> k;
  long long nl = n.length();
  vi a(nl);
  for (long long i = 0; i < nl; i++) {
    a[i] = n[nl - 1 - i] - 48;
  }
  vvvi dp = vvvi(nl, vvi(4, vi(2, 0)));
  for (long long i = 0; i < nl; i++) {
    dp[i][0][0] = 1;
    dp[i][0][1] = 1;
  }
  dp[0][1][0] = a[0];
  dp[0][1][1] = 9;
  for (long long j = 1; j < 4; j++) {
    for (long long i = 1; i < nl; i++) {
      dp[i][j][0] = dp[i - 1][j - 1][0] + (a[i] - 1) * dp[i - 1][j - 1][1] +
                    dp[i - 1][j][1];
      dp[i][j][1] = dp[i - 1][j][1] + 9LL * dp[i - 1][j - 1][1];
    }
  }
  cout << dp[nl - 1][k][0] << endl;
  return 0;
}
