#include <bits/stdc++.h>
using namespace std;
long long dp[101][4][2];
long long find(string str, long long tight, long long cnt, long long n,
               long long pos, long long g) {
  if (pos == n) {
    if (cnt == g) {
      return 1;
    } else
      return 0;
  }
  if (dp[pos][cnt][tight] != -1) return dp[pos][cnt][tight];
  if (cnt > g) return 0;
  long long x = str[pos] - '0';
  if (tight == 0) x = 9;
  long long val = 0;
  for (long long i = 0; i <= x; i++) {
    if (i == 0) {
      val += find(str, tight & (str[pos] == i + '0'), cnt, n, pos + 1, g);
    } else
      val += find(str, tight & (str[pos] == i + '0'), cnt + 1, n, pos + 1, g);
  }
  dp[pos][cnt][tight] = val;
  return val;
}
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  string str;
  cin >> str;
  long long k;
  cin >> k;
  for (long long i = 0; i < 101; i++) {
    for (long long j = 0; j < 4; j++) {
      for (long long k = 0; k < 2; k++) dp[i][j][k] = -1;
    }
  }
  long long n = str.size();
  long long ans = find(str, 1, 0, n, 0, k);
  cout << ans << "\n";
  return 0;
}
