#include <bits/stdc++.h>
using namespace std;
vector<int> num;
const int N = 2000;
int n, k;
int dp[N][5][2];
int d(int pos, int c, int f) {
  if (c > k) return 0;
  if (pos == num.size()) {
    if (c == k) {
      return 1;
    }
    return 0;
  }
  if (dp[pos][c][f] != -1) return dp[pos][c][f];
  int res = 0;
  int x;
  if (f == 0) {
    x = num[pos];
  } else {
    x = 9;
  }
  for (int i = 0; i <= x; i++) {
    int nf = f;
    int ncnt = c;
    if (f == 0 && i < x) nf = 1;
    if (i != 0) ncnt++;
    if (ncnt <= k) res += d(pos + 1, ncnt, nf);
  }
  return dp[pos][c][f] = res;
}
int solve(int b) {
  num.clear();
  while (b > 0) {
    int tmp = b % 10;
    num.push_back(tmp);
    b /= 10;
  }
  reverse(num.begin(), num.end());
  memset(dp, -1, sizeof(dp));
  int res = d(0, 0, 0);
  return res;
}
int main() {
  scanf("%d%d", &n, &k);
  int res = solve(n);
  printf("%d", res);
}
