#include <bits/stdc++.h>
using namespace std;
long long ans = 0;
void dfs(vector<int> &A, vector<int> B, int K) {
  if (A.size() > B.size()) return;
  if (A.size() == B.size()) {
    bool judge = 1;
    for (int i = 0; i < (int)(A.size()); i++) {
      if (A[i] > B[i]) return;
      if (A[i] < B[i]) {
        break;
      }
    }
  }
  if (A.size() >= K) {
    int cnt = 0;
    for (auto a : A) {
      if (a != 0) cnt++;
    }
    if (cnt == K) ans++;
  }
  for (int v = 0; v < 10; ++v) {
    if (A.size() == 0 && v == 0) continue;
    A.push_back(v);
    dfs(A, B, K);
    A.pop_back();
  }
}
int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  vector<int> A, B;
  for (int i = 0; i < (int)(s.size()); i++) {
    B.push_back(s[i] - '0');
  }
  dfs(A, B, K);
  cout << ans << endl;
}
