#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18 + 18;
const long long MAX = 100005;
const long long MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
bool chmin(T &a, const T &b) {
  if (b < a) {
    a = b;
    return true;
  }
  return false;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
template <typename T>
istream &operator>>(istream &i, vector<T> &v) {
  for (long long j = (0); j < (v.size()); j++) i >> v[j];
  return i;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << "	";
  }
  return s;
}
template <typename T>
ostream &operator<<(ostream &s, const vector<vector<T>> &vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}
long long dp[101][2][5];
void debug(long long i, long long j, long long l) {
  for (long long x = (0); x < (i); x++) {
    for (long long y = (0); y < (j); y++) {
      for (long long z = (0); z < (l); z++) {
        if (x == 0) continue;
        cerr << x << " " << y << " " << z << endl;
        cerr << "dp[x][y][z]"
             << ":" << dp[x][y][z] << endl;
        ;
      }
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << std::setprecision(10);
  memset(dp, 0, sizeof(dp));
  string s;
  long long K;
  cin >> s >> K;
  long long n = s.length();
  dp[0][0][0] = 1;
  for (long long i = (0); i < (n); i++) {
    for (long long j = (0); j < (2); j++) {
      for (long long k = (0); k < (K + 1); k++) {
        if (j == 1) {
          dp[i + 1][1][k] += dp[i][1][k];
          dp[i + 1][1][k + 1] += dp[i][1][k] * 9;
        } else {
          long long x = s[i] - '0';
          dp[i + 1][1][k] += dp[i][0][k];
          if (x == 0) continue;
          dp[i + 1][0][k + 1] += dp[i][0][k];
          dp[i + 1][1][k + 1] += dp[i][0][k] * (x - 1);
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = (0); i < (2); i++) {
    ans += dp[n][i][K];
  }
  cout << ans << endl;
  return 0;
}
