#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
struct io {
  io() {
    ios::sync_with_stdio(false);
    cin.tie(0);
  }
};
const int INF = INT_MAX;
const long long int LLINF = 1LL << 60;
const long long int MOD = 1000000007;
const double EPS = 1e-9;
int main(void) {
  string s;
  cin >> s;
  int n = s.size(), K;
  cin >> K;
  int dp[n + 1][K + 2][2];
  for (int i = 0; i < (n + 1); ++i)
    for (int j = 0; j < (K + 2); ++j)
      for (int l = 0; l < (2); ++l) dp[i][j][l] = 0;
  dp[0][1][0] = s[0] - '0' - 1;
  dp[0][1][1] = 1;
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    if (s[i] == '0') {
      dp[i + 1][K][1] += dp[i][K][1];
      dp[i + 1][K][0] += dp[i][K][0];
      dp[i + 1][K + 1][0] += dp[i][K][0] * 9;
    } else {
      dp[i + 1][K + 1][1] += dp[i][K][1];
      dp[i + 1][K][0] += dp[i][K][0];
      dp[i + 1][K + 1][0] += dp[i][K][0] * (s[i] - '0');
    }
    for (int j = 0; j < K; j++) {
      for (int k = 0; k < 2; k++) {
        if (k == 0) {
          dp[i + 1][j][0] += dp[i][j][0];
          for (int m = 1; m <= 9; m++) {
            dp[i + 1][j + 1][0] += dp[i][j][0];
          }
        } else {
          if (s[i] == '0')
            dp[i + 1][j][1] += dp[i][j][1];
          else
            dp[i + 1][j][0] += dp[i][j][1];
          for (int m = 1; m < s[i] - '0'; m++) {
            dp[i + 1][j + 1][0] += dp[i][j][1];
          }
          if (s[i] != '0') {
            dp[i + 1][j + 1][1] += dp[i][j][1];
          }
        }
      }
    }
  }
  for (int I = INF; I < n + 1; I++) {
    cout << "ゆるい: ";
    for (int i = 0; i < (K + 2); ++i) cout << dp[I][i][0] << " ";
    cout << endl;
    cout << "きつい: ";
    for (int i = 0; i < (K + 2); ++i) cout << dp[I][i][1] << " ";
    cout << endl;
    cout << "-------------" << endl;
  }
  cout << dp[n - 1][K][0] + dp[n - 1][K][1] << endl;
}
