#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[4][101];
ll nz[101];
string ss;
int k;
ll res;
void solve() {
  int len = ss.size();
  for (int i = 1; i <= len; i++) {
    if (ss[i - 1] != '0')
      nz[i] = nz[i - 1] + 1;
    else
      nz[i] = nz[i - 1];
    dp[1][i] = ss[0] - '0' + 9 * (i - 1);
  }
  for (int j = 2; j <= k; j++) {
    for (int i = 2; i <= len; i++) {
      dp[j][i] += dp[j][i - 1];
      if (dp[j - 1][i - 1] > 0) {
        if (nz[i] <= j) {
          dp[j][i] += ss[i - 1] - '0' + (dp[j - 1][i - 1] - 1) * 9;
        } else {
          dp[j][i] += dp[j - 1][i - 1] * 9;
        }
      }
    }
  }
  res = dp[k][len];
}
int main() {
  getline(cin, ss);
  cin >> k;
  solve();
  cout << res << endl;
  return 0;
}
