#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
void mainsolve() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  long long dp[101][2][101];
  long long first = s[0] - '0';
  for (long long i = 0; i < (first + 1); ++i) dp[0][i < first][i != 0]++;
  for (long long i = 0; i < (s.size() - 1); ++i)
    for (long long j = 0; j < (2); ++j)
      for (long long kk = 0; kk < (101); ++kk) {
        long long lim = j ? 9 : s[i + 1] - '0';
        for (long long next = 0; next < (lim + 1); ++next) {
          long long tmp = 0;
          if (next != 0) tmp++;
          dp[i + 1][j || next < lim][kk + tmp] += dp[i][j][kk];
        }
      }
  cout << dp[s.size() - 1][true][k] + dp[s.size() - 1][false][k] << endl;
  return;
}
int main() {
  mainsolve();
  return 0;
}
