#include <bits/stdc++.h>
using namespace std;
long long INF = LLONG_MAX;
long long dp[102][4][2];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  string s;
  int K;
  cin >> s >> K;
  memset(dp, 0, sizeof(dp));
  int n = s.length();
  dp[0][0][0] = 1;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= K; j++) {
      for (int k = 0; k < 2; k++) {
        if (dp[i][j][k] == 0) continue;
        for (int num = 0; num < 10; num++) {
          int cur = s[i] - '0';
          if (k == 0 && num > cur) continue;
          dp[i + 1][j + (num > 0)][k | (num < cur)] += dp[i][j][k];
        }
      }
    }
  }
  sum += dp[n][K][0] + dp[n][K][1];
  cout << sum << endl;
}
