#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9 + 7;
const long long longinf = 1LL << 60;
const int mx = 100010;
const long long mod = 1e9 + 7;
vector<vector<vector<long long>>> dp(
    110, vector<vector<long long>>(2, vector<long long>(5, 0)));
string s;
int d;
int main() {
  cin >> s >> d;
  int sz = s.size();
  dp[0][0][0] = 1;
  dp[1][0][0] = 1;
  dp[1][0][1] = (int)(s[0] - '0') - 1;
  dp[1][1][1] = 1;
  for (int idx = 1; idx < sz; idx++)
    for (int k = (int)(0); k < (int)(d + 1); ++k) {
      dp[idx + 1][0][k + 1] += dp[idx][0][k] * 9;
      dp[idx + 1][0][k] += dp[idx][0][k];
      int maxi = (int)(s[idx] - '0');
      if (maxi != 0) {
        dp[idx + 1][0][k + 1] += dp[idx][1][k] * (maxi - 1);
      }
      dp[idx + 1][1][k + 1] += dp[idx][1][k];
      dp[idx + 1][0][k] += dp[idx][1][k];
    }
  long long ans = dp[sz][0][d] + dp[sz][1][d];
  cout << ans << endl;
  return 0;
}
