#include <bits/stdc++.h>
using namespace std;
using edge = struct {
  long long to;
  long long cost;
};
using point = struct {
  long long x;
  long long y;
};
typedef std::priority_queue<long long, std::vector<long long>,
                            greater<long long>>
    pql;
const long long MOD = 1e9 + 7;
const long long INF = MOD * MOD;
const long double EPS = 1e-9;
const long double PI = 3.14159265358979323846;
class UnionFind {
  std::vector<long long> parents, set_size;

 public:
  UnionFind() {}
  UnionFind(long long n) {
    parents = set_size = std::vector<long long>(n);
    for (long long(i) = 0; (i) < (n); (i)++) {
      parents[i] = i;
      set_size[i] = 1LL;
    }
  }
  long long root_find(long long x) {
    if (parents[x] == x) return x;
    return parents[x] = root_find(parents[x]);
  }
  void unite(long long x, long long y) {
    x = root_find(x);
    y = root_find(y);
    if (x == y) return;
    if (set_size[x] < set_size[y]) {
      parents[y] = x;
      set_size[x] += set_size[y];
    } else {
      parents[x] = y;
      set_size[y] += set_size[x];
    }
  }
  bool is_same(long long x, long long y) {
    return root_find(x) == root_find(y);
  }
  long long size(long long x) { return set_size[root_find(x)]; }
};
struct BIT {
  long long n;
  std::vector<long long> dat;
  BIT(long long n) : dat(n + 1), n(n){};
  long long sum(long long i) {
    long long s = 0;
    while (i > 0) {
      s += dat[i];
      i -= i & -i;
    }
    return s;
  }
  long long sum(long long i, long long j) { return sum(j - 1) - sum(i - 1); }
  void add(long long i, long long x) {
    while (i <= n) {
      dat[i] += x;
      i += i & -i;
    }
  }
};
long long gcd(long long m, long long n) {
  long long a = max(m, n);
  long long b = min(m, n);
  while (b != 1 && b != 0) {
    a %= b;
    swap(a, b);
  }
  return b == 1 ? 1 : a;
}
long long lcm(long long m, long long n) { return m / gcd(m, n) * n; }
long long power_mod(long long a, long long power, long long mod) {
  long long value = 1;
  while (power != 0) {
    if (power & 1) value = (value * a) % mod;
    a = (a * a) % mod;
    power = power >> 1;
  }
  return value % mod;
}
long long modinv(long long a, long long mod) {
  return power_mod(a, mod - 2, mod);
}
long long power_normal(long long a, long long power) {
  long long value = 1;
  while (power != 0) {
    if (power & 1) value = value * a;
    a = a * a;
    power = power >> 1;
  }
  return value;
}
long long comb_memo[55][55];
long long pascal_triangle(long long n) {
  comb_memo[0][0] = 1;
  for (long long(i) = (1); (i) < (n + 1); (i)++)
    for (long long(j) = 0; (j) < (i + 1); (j)++) {
      comb_memo[i][j] += comb_memo[i - 1][j];
      if (j > 0) comb_memo[i][j] += comb_memo[i - 1][j - 1];
    }
}
long long combination(long long n, long long r, long long mod) {
  if (n == r && n == 0)
    return 1;
  else if (n <= 0 || r < 0 || r > n)
    return 0;
  long long numerator = 1;
  long long denomenator = 1;
  for (long long i = 0; i < r; i++) {
    (numerator *= long long(n - i)) %= mod;
    (denomenator *= modinv(i + 1, mod)) %= mod;
  }
  return (numerator * denomenator) % mod;
}
long long combination_memo(long long n, long long r, long long pre,
                           long long mod) {
  if (n == r && n == 0)
    return 1;
  else if (n <= 0 || r < 0 || r > n)
    return 0;
  long long numerator = long long(n - r + 1) % mod;
  long long denomenator = modinv(r, mod) % mod;
  long long val = (numerator * denomenator) % mod;
  val *= pre;
  return val % mod;
}
long long bin_search(long long key, long long A[], long long left,
                     long long right) {
  while (right >= left) {
    long long mid = left + (right - left) / 2;
    if (A[mid] == key)
      return mid;
    else if (A[mid] > key)
      right = mid - 1;
    else if (A[mid] < key)
      left = mid + 1;
  }
  return -1;
}
long long lower_bound_bin_search_temp(long long key, long long A[],
                                      long long left, long long right) {
  if (A[left] >= key) return left;
  long long mid = left + (right - left) / 2;
  while (right >= left) {
    mid = left + (right - left) / 2;
    if (mid == left) {
      if (A[left] < key && key <= A[left + 1])
        return left + 1;
      else
        return -1;
    }
    if (A[mid - 1] < key && key <= A[mid])
      return mid;
    else if (A[mid - 1] >= key)
      right = mid - 1;
    else if (A[mid] < key)
      left = mid;
  }
  return -1;
}
long long inf_bin_search_temp(long long key, long long A[], long long left,
                              long long right) {
  if (A[left] > key) return left;
  long long mid = left + (right - left) / 2;
  while (right >= left) {
    mid = left + (right - left) / 2;
    if (mid == left) {
      if (A[left] <= key && key < A[left + 1])
        return left + 1;
      else
        return -1;
    }
    if (A[mid - 1] <= key && key < A[mid])
      return mid;
    else if (A[mid - 1] > key)
      right = mid - 1;
    else if (A[mid] <= key)
      left = mid;
  }
  return -1;
}
long long upper_bound_bin_search_temp(long long key, long long A[],
                                      long long left, long long right) {
  if (A[right] <= key) return right;
  long long mid = left + (right - left) / 2;
  while (right >= left) {
    mid = left + (right - left) / 2;
    if (mid == right) {
      if (A[right - 1] <= key && key < A[right])
        return right - 1;
      else
        return -1;
    }
    if (A[mid] <= key && key < A[mid + 1])
      return mid;
    else if (A[mid] > key)
      right = mid;
    else if (A[mid + 1] <= key)
      left = mid + 1;
  }
  return -1;
}
long long sup_bin_search_temp(long long key, long long A[], long long left,
                              long long right) {
  if (A[right] < key) return right;
  long long mid = left + (right - left) / 2;
  while (right >= left) {
    mid = left + (right - left) / 2;
    if (mid == right) {
      if (A[right - 1] < key && key <= A[right])
        return right - 1;
      else
        return -1;
    }
    if (A[mid] < key && key <= A[mid + 1])
      return mid;
    else if (A[mid] >= key)
      right = mid;
    else if (A[mid + 1] < key)
      left = mid + 1;
  }
  return -1;
}
long long bin_search_vector(long long key, std::vector<long long> v,
                            long long left, long long right) {
  while (right >= left) {
    long long mid = left + (right - left) / 2;
    if (v[mid] == key)
      return mid;
    else if (v[mid] > key)
      right = mid - 1;
    else if (v[mid] < key)
      left = mid + 1;
  }
  return -1;
}
long long lower_bound_bin_search_vector(long long key,
                                        std::vector<long long> v) {
  return lower_bound((v).begin(), (v).end(), key) - v.begin();
}
long long inf_bin_search_vector(long long key, std::vector<long long> v) {
  return lower_bound((v).begin(), (v).end(), key + 1) - v.begin();
}
long long upper_bound_bin_search_vector(long long key,
                                        std::vector<long long> v) {
  return upper_bound((v).begin(), (v).end(), key) - v.begin() - 1;
}
long long sup_bin_search_vector(long long key, std::vector<long long> v) {
  return upper_bound((v).begin(), (v).end(), key - 1) - v.begin() - 1;
}
long long fact(long long n) {
  if (n == 0) return 1;
  return n * fact(n - 1);
}
bool is_prime(long long n) {
  if (n <= 1) return false;
  for (long long i = 2; i * i <= n; i++) {
    if (n % i == 0) return false;
  }
  return true;
}
long long bool_sum(long long a1, long long a2) {
  if (a1 == 1 || a2 == 1) return 1;
  return 0;
}
std::map<long long, long long> prime_decomposition(long long n) {
  long long i = 2;
  std::map<long long, long long> table;
  while (i * i <= n) {
    while (n % i == 0) {
      table[i]++;
      n /= i;
    }
    i++;
  }
  if (n > 1) table[n] = 1;
  return table;
}
long long char_to_idx(char c) {
  long long idx = 0;
  for (char(cc) = ('a'); (cc) <= ('z'); (cc)++) {
    if (c == cc)
      return idx;
    else
      idx++;
  }
}
bool is_cross(long long x1, long long y1, long long x2, long long y2,
              long long x3, long long y3, long long x4, long long y4) {
  long long val1 = (x1 - x2) * (y3 - y1) + (y1 - y2) * (x1 - x3);
  long long val2 = (x1 - x2) * (y4 - y1) + (y1 - y2) * (x1 - x4);
  long long val3 = (x3 - x4) * (y1 - y3) + (y3 - y4) * (x3 - x1);
  long long val4 = (x3 - x4) * (y2 - y3) + (y3 - y4) * (x3 - x2);
  return val1 * val2 < 0 && val3 * val4 < 0;
}
const long long MAX_N = 100005;
bool okay = false;
long long answer = 0;
long long n, k;
string s;
void solve() {
  n = s.length();
  long long nine = power_normal(9, k);
  for (long long(i) = 0; (i) < (n - k); (i)++) {
    answer += combination(n - 2 - i, k - 1, MOD) * nine;
  }
  long long m = long long((s[0])) - long long('0');
  if (k == 1)
    answer += m;
  else if (k == 2) {
    answer += (m - 1) * (n - 1) * 9;
    bool did_zero = true;
    for (long long(i) = (1); (i) < (n); (i)++) {
      if (did_zero)
        answer += long long((s[i])) - long long('0');
      else
        answer += 9;
      if (s[i] != '0') did_zero = false;
    }
  } else if (k == 3) {
    answer += (m - 1) * (n - 1) * (n - 2) / 2 * 81;
    bool did_zero0 = true;
    bool did_zero1 = true;
    bool did_zero2 = true;
    for (long long(i1) = (1); (i1) < (n - 1); (i1)++) {
      if (!did_zero0 && s[i1] != '0') did_zero1 = false;
      if (did_zero0 && s[i1] == '0')
        continue;
      else
        did_zero0 = false;
      if (did_zero1)
        answer += (long long((s[i1])) - long long('0') - 1) * (n - 1 - i1) * 9;
      else {
        answer += 9 * (n - 1 - i1) * 9;
        continue;
      }
      did_zero2 = true;
      for (long long(i2) = (i1 + 1); (i2) < (n); (i2)++) {
        if (did_zero2)
          answer += long long((s[i2])) - long long('0');
        else
          answer += 9;
        if (s[i2] != '0') did_zero2 = false;
      }
    }
  }
  cout << (answer) << endl;
}
int main(void) {
  cin >> (s) >> (k);
  solve();
  return 0;
}
