#include <bits/stdc++.h>
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double eps = 0.000000001;
using namespace std;
long long dp[110][2][120];
signed main() {
  string n;
  long long k2;
  cin >> n >> k2;
  long long nsize = n.size();
  dp[0][0][0] = 1;
  for (long long i = 0; (i) < (nsize); ++(i)) {
    for (long long j = 0; (j) < (2); ++(j)) {
      for (long long k = 0; (k) < (5); ++(k)) {
        if (j == 0) {
          for (long long x = 0; x <= (long long)(n[i] - '0'); x++) {
            if (x == (long long)(n[i] - '0')) {
              dp[i + 1][0][k + 1] += dp[i][j][k];
            } else if (x == 0) {
              dp[i + 1][1][k] += dp[i][j][k];
            } else {
              dp[i + 1][1][k + 1] += dp[i][j][k];
            }
          }
        } else {
          for (long long x = 0; x <= 9; x++) {
            if (x == 0) {
              dp[i + 1][1][k] += dp[i][j][k];
            } else {
              dp[i + 1][1][k + 1] += dp[i][j][k];
            }
          }
        }
      }
    }
  }
  cout << dp[nsize][0][k2] + dp[nsize][1][k2] << endl;
  return 0;
}
