#include <bits/stdc++.h>
using namespace std;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;
int K, N;
string S;
long long dfs(int pos, int tmpK, int flag = false) {
  if (tmpK == 0) {
    return (long long)1;
  }
  if (pos >= N) {
    return (long long)0;
  }
  long long ans = 0;
  ans += dfs(pos + 1, tmpK, true);
  if (flag) {
    ans += 9 * dfs(pos + 1, tmpK - 1, true);
  } else {
    int n = (S[pos] - '0') - 1;
    if (n > 0) {
      ans += n * dfs(pos + 1, tmpK - 1, true);
    }
    if (S[pos] - '0' != 0) {
      ans += dfs(pos + 1, tmpK - 1, false);
    }
  }
  return ans;
}
int main() {
  cin >> S >> K;
  N = S.length();
  vector<int> arr;
  long long ans = dfs(0, K);
  cout << ans << endl;
  return 0;
}
