#include <bits/stdc++.h>
using namespace std;
const int MAXN = 1e3 + 5;
int d[MAXN];
int nbdig;
long long dp[101][5][3];
long long solve(int i, int cnt, int exact) {
  if (i >= nbdig) return (cnt == 0);
  long long &ret = dp[i][cnt][exact];
  if (ret != -1) return ret;
  ret = 0;
  if (exact) {
    ret += solve(i + 1, cnt - (d[i] > 0), 1);
    for (int j = 0; j < d[i]; j++) ret += solve(i + 1, cnt - (j > 0), 0);
  } else {
    for (int j = 0; j <= 9; j++) ret += solve(i + 1, cnt - (j > 0), 0);
  }
  return ret;
}
long long get(string s, int k) {
  nbdig = (int)s.size();
  for (int i = 0; i < nbdig; i++) {
    d[i] = s[i] - '0';
  }
  return solve(0, k, 1);
}
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  memset(dp, -1, sizeof(dp));
  cout << get(s, k);
}
