#include <bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1 << 30) - 1;
const long long INFLL = (1LL << 62) - 1;
inline int in() {
  int x;
  scanf("%d", &x);
  return x;
}
template <typename tuple<int, int, int> >
inline long long suma(const vector<tuple<int, int, int> >& a) {
  long long res(0);
  for (auto&& x : a) res += x;
  return res;
}
template <class tuple<int, int, int> >
inline bool chmax(tuple<int, int, int>& a, tuple<int, int, int> b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
} template <class tuple<int, int, int> >
inline bool chmin(tuple<int, int, int>& a, tuple<int, int, int> b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
} int dp[105][4][2];
int main() {
  string s;
  int K;
  cin >> s >> K;
  int n = s.size();
  dp[0][0][0] = 1;
  for (int i = (0); i < (n); ++i)
    for (int j = (0); j < (4); ++j)
      for (int k = (0); k < (2); ++k) {
        int nd = s[i] - '0';
        for (int d = (0); d < (10); ++d) {
          int ni = i + 1, nj = j, nk = k;
          if (nd != 0) nj++;
          if (nj > K) continue;
          if (k == 0) {
            if (d > nd) continue;
            if (d < nd) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
  cout << dp[n][K][0] + dp[n][K][1] << endl;
  return 0;
}
