#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse4")
using namespace std;
template <class T>
bool ckmin(T& a, const T& b) {
  return b < a ? a = b, 1 : 0;
}
template <class T>
bool ckmax(T& a, const T& b) {
  return a < b ? a = b, 1 : 0;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const long double pii = 3.14159265359;
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001;
string str;
int K;
int N;
map<pair<int, int>, long long> m1, m2;
long long calc(bool eq, int k, int level) {
  if (k == 0) return 1;
  if (level == N) return 0;
  if (str[level] == '0') {
    return calc(true, k, level + 1);
  }
  if (eq) {
    if (m1.find({k, level}) != m1.end()) return m1[{k, level}];
    return m1[{k, level}] =
               calc(true, k - 1, level + 1) + calc(false, k, level + 1) +
               (str[level] - '0' - 1) * calc(false, k - 1, level + 1);
  } else {
    if (m2.find({k, level}) != m2.end()) return m2[{k, level}];
    return m2[{k, level}] =
               9 * calc(false, k - 1, level + 1) + calc(false, k, level + 1);
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> str;
  cin >> K;
  N = (int)(str).size();
  cout << calc(true, K, 0);
  return 0;
}
