#include <bits/stdc++.h>
using namespace std;
long long const MOD = 1e9 + 7;
int const inf = 1e9;
long long const INF = 1e18;
inline void ios_() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}
template <typename T>
int size(const T& a) {
  return (int)a.size();
}
template <typename T>
T Div(T a, T b) {
  return (a + b - 1) / b;
}
template <typename T>
bool chmin(T& a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmax(T& a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct Solver {
  int n;
  int k;
  vector<int> v;
  vector<vector<long long>> dp;
  Solver(string s, int k) : k(k) {
    n = s.size();
    v.resize(n);
    for (int(i) = 0; (i) < (n); (i)++) {
      v[i] = s[n - 1 - i] - '0';
    }
    dp = vector<vector<long long>>(n + 1, vector<long long>(4, INF));
    for (int(i) = 0; (i) < (n + 1); (i)++) dp[i][0] = 1;
    dp[0][1] = 0;
    dp[0][2] = 0;
    dp[0][3] = 0;
  }
  long long f(long long n, long long z) {
    if (z == 0) {
      return 1;
    } else if (z < 0 || n < z) {
      return 0;
    } else if (z == 1) {
      return 9 * n;
    } else if (z == 2) {
      return 9 * 9 * n * (n - 1) / 2;
    } else {
      return 9 * 9 * 9 * n * (n - 1) * (n - 2) / 6;
    }
  }
  long long rec(int n, int z) {
    if (dp[n][z] < INF) return dp[n][z];
    if (n == 0) return dp[n][z];
    dp[n][z] = (v[n - 1] > 0) * (rec(n - 1, z - 1) + f(n - 1, z)) +
               max(0, (v[n - 1] - 1)) * f(n - 1, z - 1);
    return dp[n][z];
  }
  void solve() { cout << rec(n, k) << endl; }
};
signed main() {
  string s;
  int k;
  cin >> s >> k;
  Solver S(s, k);
  S.solve();
  return 0;
}
