#include <bits/stdc++.h>
using namespace std;
string s;
int N, K;
int dp[2][101][4][2];
long long solve(bool started, int n, int nz, bool smaller) {
  if (n == N) return (nz == K) && started;
  if (dp[started][n][nz][smaller] != -1) return dp[started][n][nz][smaller];
  long long ret = 0;
  if (nz == K)
    ret += solve(1, n + 1, nz, smaller || (s[n] > '0'));
  else if (nz < K) {
    ret += solve(started, n + 1, nz, smaller || (s[n] > '0'));
    if (smaller)
      for (char h = '1'; h <= '9'; h++) ret += solve(1, n + 1, nz + 1, 1);
    else {
      for (char h = '1'; h < s[n]; h++) ret += solve(1, n + 1, nz + 1, 1);
      ret += solve(1, n + 1, nz + int(s[n] != '0'), 0);
    }
  }
  return dp[started][n][nz][smaller] = ret;
}
int main() {
  cin >> s >> K;
  N = s.size();
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0, 0, 0) << endl;
  return 0;
}
