#include <bits/stdc++.h>
using namespace std;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class Type>
struct is_vector : std::false_type {};
template <class ValueType, class Alloc>
struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
template <typename T>
inline std::ostream& operator<<(std::ostream& out, const std::vector<T>& v) {
  if (v.empty()) return out;
  constexpr bool is_vector_v = is_vector<T>::value;
  if (is_vector_v)
    for (auto itr = v.begin(); itr != v.end();)
      out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
  else
    for (auto itr = v.begin(); itr != v.end();)
      out << (*itr), out << ((++itr != v.end()) ? " " : "");
  return out;
}
inline void put() {}
template <class T>
inline void put(const T& first) {
  std::cout << first << "\n";
}
template <class T, class... N>
inline void put(const T& first, const N&... rest) {
  std::cout << first << " ";
  put(rest...);
}
inline void putn() {}
template <class T, class... N>
inline void putn(const T& first, const N&... rest) {
  std::cout << first << "\n";
  putn(rest...);
}
int main() {
  cin.tie(0), ios::sync_with_stdio(false);
  string s;
  long long k;
  cin >> s >> k;
  long long n = s.size();
  vector<long long> a(n);
  for (long long i = 0; i < (long long)(n); i++) {
    a[i] = s[i] - '0';
  }
  long long dp[200][200][2];
  for (long long i = 0; i < (long long)(200); i++) {
    for (long long j = 0; j < (long long)(200); j++) {
      for (long long k = 0; k < (long long)(2); k++) {
        dp[i][j][k] = 0;
      }
    }
  }
  dp[0][0][0] = 1;
  dp[0][1][1] = 1;
  dp[0][0][1] = a[0] - 1;
  for (long long i = 0; i < (long long)(n - 1); i++) {
    if (a[i + 1] == 0) {
      for (long long j = 0; j < (long long)(n); j++) {
        dp[i + 1][j + 1][0] += dp[i][j][0];
      }
    } else {
      for (long long j = 0; j < (long long)(n); j++) {
        dp[i + 1][j][0] += dp[i][j][0];
      }
      for (long long j = 0; j < (long long)(n); j++) {
        dp[i + 1][j + 1][1] += dp[i][j][0];
      }
    }
    for (long long j = 0; j < (long long)(n); j++) {
      dp[i + 1][j][1] += max(0ll, a[i + 1] - 1ll) * dp[i][j][0];
      dp[i + 1][j][1] += dp[i][j][1] * 9ll;
      dp[i + 1][j + 1][1] += dp[i][j][1];
    }
  }
  long long res = 0;
  res += dp[n - 1][n - k][0];
  res += dp[n - 1][n - k][1];
  put(res);
  return 0;
}
