#include <bits/stdc++.h>
using namespace std;
string N;
vector<int> n;
long long dp[100][2][10];
int main(void) {
  cin >> N;
  int K;
  cin >> K;
  for (auto a : N) {
    n.push_back(a - '0');
  }
  int l = N.size();
  dp[0][0][0] = 1;
  for (int i = 0; i < l; i++) {
    for (int smaller = 0; smaller < 2; smaller++) {
      for (int j = 0; j <= K; j++) {
        for (int x = 0; x <= (smaller ? 9 : n[i]); x++) {
          if (x == 0) {
            dp[i + 1][smaller || x < n[i]][j] += dp[i][smaller][j];
          } else {
            if (j + 1 <= K)
              dp[i + 1][smaller || x < n[i]][j + 1] += dp[i][smaller][j];
          }
        }
      }
    }
  }
  cout << dp[l][0][K] + dp[l][1][K] << endl;
}
