#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
long long dp[110][10][2];
int main() {
  string n;
  cin >> n;
  int k;
  cin >> k;
  dp[0][0][0] = 1;
  for (int i = 0; i < (int)n.size(); i++)
    for (int j = 0; j < 4; j++)
      for (int K = 0; K < 2; K++) {
        int nx = n[i] = '0';
        for (int d = 0; d < 10; d++) {
          int ni = i + 1, nj = j, nk = K;
          if (d != 0) nj++;
          if (nj > k) continue;
          if (K == 0) {
            if (d > nx) continue;
            if (d < nx) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][K];
        }
      }
  long long ans = dp[n.size()][k][0] + dp[n.size()][k][1];
  cout << ans << endl;
  return 0;
}
