#include <bits/stdc++.h>
using namespace std;
long long int power(long long int a, long long int b) {
  long long int ans = 1;
  long long int t = a;
  while (b) {
    if (b % 2) {
      ans = (ans * t) % 1000000007;
    }
    t = (t * t) % 1000000007;
    b /= 2;
  }
  return ans;
}
long long int comb(long long int n, long long int c) {
  if (c == 0 || c == n) return 1;
  long long int ans = 1;
  for (long long int i = n - c + 1; i < n + 1; i++) {
    ans *= i;
  }
  for (long long int i = 2; i < c + 1; i++) {
    ans /= i;
  }
  return ans;
}
long long int f(long long int n, long long int d) {
  return comb(n, d) * power(9, d);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  string s;
  long long int k;
  cin >> s >> k;
  long long int n = s.size();
  long long int dp[n][k + 1];
  memset(dp, 0, sizeof dp);
  dp[n - 1][0] = 1;
  dp[n - 1][1] = s.back() - '0';
  for (long long int i = n - 2; i >= 0; i--) {
    dp[i][0] = 1;
    for (char c = '0'; c < s[i]; c++) {
      for (long long int j = 1; j < k + 1; j++) {
        dp[i][j] += f(n - i - 1, (c == '0' ? j : j - 1));
      }
    }
    if (s[i] > '0') {
      for (long long int j = 1; j < k + 1; j++) {
        dp[i][j] += dp[i + 1][j - 1];
      }
    }
  }
  cout << dp[0][k];
}
