#include <bits/stdc++.h>
using namespace std;
long long mod = 1000000007;
long long gcd(long long a, long long b) { return (b == 0) ? a : gcd(b, a % b); }
long long power(long long x, long long y,
                long long pair<long long, long long> = mod) {
  long long res = 1;
  x = x % pair<long long, long long>;
  while (y > 0) {
    if (y & 1) {
      res = (res * x) % pair<long long, long long>;
    }
    y = y >> 1;
    x = (x * x) % pair<long long, long long>;
  }
  return res;
}
long long fun(long long n, vector<long long> &v, long long k, long long i,
              long long j, bool allow,
              vector<vector<vector<long long> > > &dp) {
  if (i == n && j == k) {
    return 1;
  }
  if (i == n) {
    return 0;
  }
  if (j == k) {
    return 1;
  }
  if (dp[i][j][allow] != -1) {
    return dp[i][j][allow];
  }
  long long ans = 0;
  if (allow == true) {
    for (long long x = 0; x <= v[i]; x++) {
      if (x == 0) {
        ans += fun(n, v, k, i + 1, j, false, dp);
      } else if (x == v[i]) {
        ans += fun(n, v, k, i + 1, j + 1, true, dp);
      } else {
        ans += fun(n, v, k, i + 1, j + 1, false, dp);
      }
    }
  } else {
    for (long long x = 0; x <= 9; x++) {
      if (x == 0) {
        ans += fun(n, v, k, i + 1, j, false, dp);
      } else {
        ans += fun(n, v, k, i + 1, j + 1, false, dp);
      }
    }
  }
  return dp[i][j][allow] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  string s;
  cin >> s;
  long long k;
  cin >> k;
  vector<long long> v;
  for (long long i = 0; i < s.size(); i++) {
    v.push_back(s[i] - 48);
  }
  long long n = s.size();
  vector<vector<vector<long long> > > dp(
      n + 1, vector<vector<long long> >(k + 1, vector<long long>(3, -1)));
  long long ans = fun(n, v, k, 0, 0, true, dp);
  cout << ans << endl;
  return 0;
}
