#include <bits/stdc++.h>
using namespace std;
template <class S, class T>
pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first + t.first, s.second + t.second);
}
template <class S, class T>
pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) {
  return pair<S, T>(s.first - t.first, s.second - t.second);
}
template <class S, class T>
ostream &operator<<(ostream &os, pair<S, T> p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
const long long inf = 1000000001;
const long long INF = (long long)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
vector<long long> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vector<long long> dx2 = {1, 1, 0, -1, -1, -1, 0, 1},
                  dy2 = {0, 1, 1, 1, 0, -1, -1, -1};
const long long MOD = 1000000007;
signed main() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long n = s.size();
  vector<vector<vector<long long> > > dp(
      n + 1, vector<vector<long long> >(k + 1, vector<long long>(2)));
  dp[0][0][0] = 1;
  for (long long keta = 0; keta < (n); keta++) {
    long long nketa = keta + 1;
    for (long long j = 0; j < (k + 1); j++) {
      for (long long giri = 0; giri < (2); giri++) {
        for (long long add = 0; add < (10); add++) {
          long long ngiri = 0;
          if (giri and s[keta] - '0' < add) continue;
          if (giri and s[keta] - '0' == add) ngiri = 1;
          long long nj = j;
          if (add != 0) nj++;
          if (nj > k) continue;
          dp[nketa][nj][ngiri] += dp[keta][j][giri];
        }
      }
    }
  }
  cout << dp[n][k][0] + dp[n][k][1] << endl;
}
