#include <bits/stdc++.h>
using namespace std;
bool chmin(long long int& a, long long int& b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
bool chmax(long long int& a, long long int& b) {
  if (b > a) {
    a = b;
    return 1;
  }
  return 0;
}
const long long int INF = 999999999999999;
const long long int MOD = 1000000007;
const long long int MAX_N = 500010;
long long int a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
string s;
long long int saiki(long long int x, long long int i, long long int k) {
  if (i == 0) {
    if (x == n - 1 && k == 1) return 9;
    if (k == 0) return 1;
    if (x == n - 1) return 0;
    return saiki(x + 1, 0, k) + saiki(x + 1, 0, k - 1) * 9;
  }
  a = s[x] - '0';
  if (x == n - 1 && k == 1) return a;
  if (k == 0) return 1;
  if (a == 0) return saiki(x + 1, 1, k);
  return saiki(x + 1, 0, k) + saiki(x + 1, 0, k - 1) * (a - 1) +
         saiki(x + 1, 1, k - 1);
}
int main() {
  cin >> s >> k;
  n = s.length();
  cout << saiki(0, 1, k) << endl;
}
