#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int Nctoi(char c) {
  if ('0' <= c && c <= '9') {
    return c - '0';
  } else {
    return 0;
  }
}
int main() {
  string s;
  cin >> s;
  int M = s.size();
  int K;
  cin >> K;
  vector<vector<vector<ll>>> dp(M, vector<vector<ll>>(10, vector<ll>(K + 1)));
  for (int i = 0; i < 10; i++) {
    if (i == 0) {
      dp[0][i][0] = 1;
    } else {
      dp[0][i][1] = 1;
    }
  }
  for (int d = 1; d < M; d++) {
    for (int k = 0; k <= K; k++) {
      for (int top = 0; top < 10; top++) {
        for (int ptop = 0; ptop < 10; ptop++) {
          if (top == 0) {
            dp[d][top][k] += dp[d - 1][ptop][k];
          } else {
            if (k > 0) {
              dp[d][top][k] += dp[d - 1][ptop][k - 1];
            }
          }
        }
      }
    }
  }
  ll ans = 0;
  for (int i = 0; i < M; i++) {
    int cur = Nctoi(s[i]);
    if (i == 0) {
      for (int top = 0; top < cur; top++) ans += dp[M - i - 1][top][K];
    } else if (i == M - 1) {
      for (int top = 0; top <= cur; top++) ans += dp[M - i - 1][top][K];
    } else {
      for (int top = 0; top < cur; top++) ans += dp[M - i - 1][top][K];
    }
    if (cur > 0) K--;
    if (K < 0) break;
  }
  cout << ans << "\n";
}
