#include <bits/stdc++.h>
using namespace std;
const int inf = 1 << 30;
const long long linf = 1LL << 62;
const int MAX = 510000;
long long dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
long long dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const double pi = acos(-1);
const double eps = 1e-7;
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  if (a > b) {
    a = b;
    return true;
  } else
    return false;
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  } else
    return false;
}
template <typename T1, typename T2>
inline void print2(T1 a, T2 b) {
  cout << a << " " << b << endl;
}
template <typename T1, typename T2, typename T3>
inline void print3(T1 a, T2 b, T3 c) {
  cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
long long dp[1005][4][2];
int main() {
  string s;
  cin >> s;
  long long K;
  cin >> K;
  long long n = s.size();
  dp[0][0][0] = 1;
  for (long long i = 0; i < (n); i++) {
    for (long long k = 0; k < (3); k++) {
      dp[i + 1][k + 1][1] += dp[i][k][1] * 9;
      dp[i + 1][k][1] += dp[i][k][1];
      if (s[i] == '0') {
        dp[i + 1][k][0] += dp[i][k][0];
      } else {
        dp[i + 1][k][1] += dp[i][k][0];
        for (long long j = (1); j < (s[i] - '0'); j++)
          dp[i + 1][k + 1][1] += dp[i][k][0];
        dp[i + 1][k + 1][0] += dp[i][k][0];
      }
    }
  }
  cout << dp[n][K][0] + dp[n][K][1] << endl;
}
