#include <bits/stdc++.h>
using namespace std;
bool check(int n) {
  while (n > 0) {
    if (n % 10 == 0) {
      return false;
    }
    n /= 10;
  }
  return true;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  vector<vector<long long>> C(4, vector<long long>(101, 0));
  vector<int> pow(4);
  pow[0] = 1;
  for (int i = 1; i <= 3; ++i) {
    pow[i] = pow[i - 1] * 9;
  }
  for (int j = 0; j <= 100; ++j) {
    C[0][j] = 1;
  }
  for (int i = 1; i <= 3; ++i) {
    C[i][i] = 1;
    for (int j = i + 1; j <= 100; ++j) {
      C[i][j] = C[i - 1][j - 1] + C[i][j - 1];
    }
  }
  string n;
  int k;
  cin >> n >> k;
  long long ans = 0;
  for (int i = 0; i <= k; ++i) {
    long long num = 0, cur = 0;
    for (int j = 0; j < i; ++j) {
      cur = cur * 10 + (n[j] - '0');
    }
    long long hui = 1;
    while (hui * 10 <= cur) {
      hui *= 10;
    }
    for (int j = hui; j <= cur; ++j) {
      if (check(j)) {
        num++;
      }
    }
    if (i == 0) {
      ans += C[k][n.size() - 1] * pow[k];
    } else if (i < n.size()) {
      ans += num * C[k - i][n.size() - (i + 1)] * pow[k - i];
    } else if (i == n.size()) {
      ans += num;
    }
  }
  cout << ans;
  return 0;
}
