#include <bits/stdc++.h>
using namespace std;
vector<long long int> num;
long long int k, len;
long long int dp[1001][5][2];
long long int calc(long long int pos, long long int cnt, long long int edge) {
  if (pos == len) {
    if (cnt == k) return 1;
    return 0;
  }
  if (dp[pos][cnt][edge] != -1) return dp[pos][cnt][edge];
  long long int maxdigit = 9;
  if (edge) maxdigit = num[pos];
  long long int res = 0;
  for (long long int i = 0; i <= maxdigit; i++) {
    long long int newedge = (edge & (i == maxdigit));
    long long int newcount = (cnt + (i > 0));
    res += calc(pos + 1, newcount, newedge);
  }
  return dp[pos][cnt][edge] = res;
}
signed main() {
  string s;
  cin >> s >> k;
  len = s.length();
  memset(dp, -1, sizeof(dp));
  for (long long int i = 0; i < len; i++) {
    num.push_back(s[i] - '0');
  }
  long long int ans = calc(0, 0, 1);
  cout << ans << endl;
  return 0;
}
