#include <bits/stdc++.h>
using namespace std;
ostream &operator<<(ostream &a, const vector<long long> &b) {
  for (auto k : b) cout << k << " ";
  return a;
}
const long long INF = 1e18;
const long long MAXN = 101;
long long dp[2][MAXN][4];
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  string n;
  long long k;
  cin >> n >> k;
  long long sz = n.size();
  dp[0][0][1] = n[0] - '1';
  dp[0][0][0] = 1;
  long long cnt = 1;
  dp[1][0][1] = 1;
  for (long long i = 1; i < sz; i++) {
    if (n[i] != '0') cnt++;
    if (cnt > 3) break;
    dp[1][i][cnt] = 1;
  }
  for (long long i = 1; i < sz; i++) {
    for (long long j = 0; j <= k; j++) {
      dp[0][i][j] = (n[i] != '0' ? dp[1][i - 1][j] : 0) + dp[0][i - 1][j];
      if (j != 0) {
        dp[0][i][j] +=
            9 * dp[0][i - 1][j - 1] + (n[i] - '1') * dp[1][i - 1][j - 1];
      }
    }
  }
  cout << dp[0][sz - 1][k] + dp[1][sz - 1][k];
}
