#include <bits/stdc++.h>
using namespace std;
using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;
using sc = signed char;
using si = signed int;
using sl = signed long long int;
using ld = long double;
void m_assert(const bool& cond, const sl& line, const char* condstr) {
  if (!cond) {
    cerr << "Assertion Failed: " << condstr << " at line " << line << endl;
    exit(1);
  }
}
template <class T>
T powint(T x, sl y) {
  ;
  T cur = x;
  T res = 1;
  while (y != 0) {
    if ((y & 1) == 1) {
      res = res * cur;
    }
    cur = cur * cur;
    y >>= 1;
  }
  return res;
}
template <class T>
T factorial(const T& n) {
  T res = 1;
  for (sl(i) = 0; (i) < (n); ++(i)) {
    res *= i + 1;
  }
  return res;
}
template <class T>
T permutation(const T& n, const T& m) {
  return factorial(n) / factorial(n - m);
}
template <class T>
T combination(const T& n, const T& m) {
  T res = 1;
  for (sl(i) = (n - m); (i) < (n); ++(i)) {
    res *= i + 1;
  }
  for (sl(i) = (0); (i) < (m); ++(i)) {
    res /= i + 1;
  }
  return res;
}
static string N;
static sl K;
static sl dp[100];
void solve(void) {
  sl M = N.size();
  sl j = 0;
  for (sl(i) = 0; (i) < (M); ++(i)) {
    sl n = N[i] - '0';
    sl t = 0;
    if (j < K) {
      if (n != 0) {
        if (K - j - 1 != 0) {
          t += (n - 1) * combination(M - i - 1, K - j - 1) *
               powint(9, K - j - 1);
        } else {
          t += (n - 1);
        }
      }
      t += combination(M - i - 1, K - j) * powint(9, K - j);
    }
    if (i != 0) {
      t += dp[i - 1];
    }
    dp[i] = t;
    if (n != 0) {
      j++;
    }
  }
  cout << dp[M - 1] + 1 << endl;
}
int main(void) {
  cin >> N;
  cin >> K;
  solve();
  return 0;
}
