#include <bits/stdc++.h>
using namespace std;
using ll = long long;
void comb(vector<vector<ll>> &v) {
  for (int i = 0; i < v.size(); i++) {
    v[i][0] = 1;
    v[i][i] = 1;
  }
  for (int k = 1; k < v.size(); k++) {
    for (int j = 1; j < k; j++) {
      v[k][j] = (v[k - 1][j - 1] + v[k - 1][j]);
    }
  }
}
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int l = s.size();
  int p = 1;
  for (int j = 0; j < k; j++) {
    p *= 9;
  }
  vector<vector<ll>> v(l + 1, vector<ll>(l + 1, 0));
  comb(v);
  ll ans = 0;
  for (int i = 1; i <= l; i++) {
    if (i < k) {
      continue;
    }
    if (i != l) {
      ans += p * v[i - 1][k - 1];
    } else {
      ans += (p / 9) * (int)(s[0] - '0' - 1) * v[l - 1][k - 1];
      if (k == 1) {
        ans += 1;
      } else if (k == 2) {
        int tmp = 0;
        for (int j = 1; j < l; j++) {
          if (s[j] == '0') continue;
          tmp += (s[j] - '0');
        }
        ans += tmp;
      } else if (k == 3) {
        int tmp = 0;
        for (int j = 1; j < l - 1; j++) {
          for (int x = j + 1; x < l; x++) {
            if (s[j] == '0' || s[x] == '0') continue;
            tmp += (s[j] - '0') * (s[x] - '0');
          }
        }
        ans += tmp;
      }
    }
  }
  std::cout << ans << endl;
}
