#include <bits/stdc++.h>
const int mod = 1000000007;
const int inf = 1000000009;
const long long INF = 1000000000000000009;
const long long big = 1000000000000000;
const long double eps = 0.000000000000000000001;
using namespace std;
long long DP[105][4], S[105][4];
int main() {
  ios::sync_with_stdio(false);
  cin.tie();
  cout.tie();
  string napis;
  cin >> napis;
  reverse(napis.begin(), napis.end());
  int n = napis.size();
  napis = '#' + napis;
  int k;
  cin >> k;
  S[0][0] = 1;
  DP[0][0] = 1;
  for (int i = 1; i <= n; i++) {
    int a = napis[i] - '0';
    for (int j = 0; j <= k; j++) {
      S[i][j] = S[i - 1][j];
      if (j != 0) S[i][j] += (long long)9 * S[i - 1][j - 1];
      DP[i][j] = S[i - 1][j];
      if (j != 0) {
        if (a != 0)
          DP[i][j] += (long long)(a - 1) * S[i - 1][j - 1] + DP[i - 1][j - 1];
      }
    }
  }
  cout << DP[n][k];
  return 0;
}
