#include <bits/stdc++.h>
using namespace std;
const long long MOD2 = 998244353;
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const int LIMIT = 1e6;
const long long MOD = 1e9 + 7;
vector<long long> FacMod(LIMIT), InvMod(LIMIT), FacInvMod(LIMIT);
const int dpComTableLIMIT = 3e3 + 1;
vector<vector<long long>> Com(dpComTableLIMIT,
                              vector<long long>(dpComTableLIMIT, 0));
const int ComKTableLIMIT = 1e7;
vector<long long> ComK(ComKTableLIMIT);
void DPComInit() {
  for (int i = 0; i < dpComTableLIMIT; i++) {
    Com[i][0] = 1;
  }
  for (int i = 1; i < dpComTableLIMIT; i++) {
    for (int j = 1; j < dpComTableLIMIT; j++) {
      Com[i][j] = (Com[i - 1][j - 1] + Com[i - 1][j]) % MOD;
    }
  }
}
void ComKInit(long long N) {
  for (int i = 0; i <= ComKTableLIMIT; i++) {
    if (0 < i && i <= N / 2) {
      ComK[i] = (ComK[i - 1] * (N - i + 1) / i) % MOD;
    } else if (i == 0) {
      ComK[i] = 1;
    } else if (N / 2 < i && i <= N) {
      ComK[i] = ComK[N - i];
    } else {
      ComK[i] = -1;
    }
  }
}
void ComInit() {
  FacMod[0] = FacMod[1] = 1;
  InvMod[0] = 0;
  InvMod[1] = 1;
  FacInvMod[0] = FacInvMod[1] = 1;
  for (int i = 2; i < LIMIT; i++) {
    FacMod[i] = FacMod[i - 1] * i % MOD;
    InvMod[i] = -InvMod[MOD % i] * (MOD / i) % MOD + MOD;
    FacInvMod[i] = FacInvMod[i - 1] * InvMod[i] % MOD;
  }
}
long long ComMod(int n, int k) {
  if (n >= 0 && k >= 0 && n >= k) {
    return FacMod[n] * (FacInvMod[k] * FacInvMod[n - k] % MOD) % MOD;
  } else {
    return 0;
  }
}
long long power(long long x, long long y) {
  if (y < 0) {
    return 0;
  } else if (y == 0) {
    return 1LL;
  } else if (y % 2 == 0) {
    return power(x, y / 2) * power(x, y / 2);
  } else {
    return power(x, y - 1) * x;
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  long long K;
  cin >> S;
  cin >> K;
  long long N = S.size();
  long long ans = 0;
  DPComInit();
  long long a = power(9, K);
  long long b = power(9, K - 1);
  if (N < K) {
    cout << ans << endl;
  } else {
    for (int i = K; i <= N - 1; i++) {
      ans += a * Com[i - 1][K - 1];
    }
    ans += ((S[0] - '0') - 1) * b * Com[N - 1][K - 1];
    long long f, s, first, si;
    bool fb = 0, sb = 0;
    for (int i = 2; i <= N; i++) {
      if (!fb && S[i - 1] != '0') {
        f = S[i - 1] - '0';
        first = N - i + 1;
        fb = 1;
      } else if (!sb && S[i - 1] != '0') {
        s = S[i - 1] - '0';
        si = N - i + 1;
        sb = 1;
      }
    }
    switch (K - 1) {
      case 0:
        ans += 1;
        break;
      case 1:
        if (fb) {
          ans += f + 9 * (first - 1);
        } else {
          ans += 0;
        }
        break;
      case 2:
        if (fb && sb) {
          ans += b * Com[first - 1][2];
          ans += (f - 1) * 9 * Com[first - 1][1];
          ans += 1 * 9 * Com[si - 1][1];
          ans += 1 * s;
        } else {
          ans += 0;
        }
        break;
      default:
        break;
    }
  }
  cout << ans << endl;
  return 0;
}
