#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
ll nCr(int n, int r) {
  if (r * 2 > n) r = n - r;
  ll dividend = 1;
  ll divisor = 1;
  for (int i = (1); i < (r + 1); i++) {
    dividend *= (n - i + 1);
    divisor *= i;
  }
  return dividend / divisor;
}
int main() {
  string n;
  cin >> n;
  int k;
  cin >> k;
  vector<int> a(int(n.size()));
  for (int i = 0; i < (int(n.size())); i++) a[i] = n[i] - '0';
  int keta = int(a.size());
  ;
  int ans = 0;
  if (k == 1) {
    for (int i = (1); i < (10); i++) {
      for (int j = (1); j < (keta + 1); j++) {
        if (j < keta)
          ans++;
        else if (a[0] >= i)
          ans++;
      }
    }
  } else if (k == 2) {
    for (int i = (1); i < (10); i++) {
      for (int j = (k); j < (keta + 1); j++) {
        if (j < keta)
          ans += 9 * nCr(j - 1, k - 1);
        else {
          if (a[0] > i) {
            ans += 9 * nCr(j - 1, k - 1);
          } else if (a[0] == i) {
            int loc = 1;
            while (a[loc] == 0) {
              loc++;
              if (loc == keta) break;
            }
            if (loc == keta) continue;
            ;
            for (int l = (1); l < (10); l++) {
              if (l <= a[loc]) {
                ans += keta - loc;
              } else {
                ans += keta - loc - 1;
              }
            }
          }
        }
      }
    }
  } else {
    for (int i = (1); i < (10); i++) {
      for (int j = (k); j < (keta + 1); j++) {
        if (j < keta)
          ans += 81 * nCr(j - 1, k - 1);
        else {
          if (a[0] > i) {
            ans += 81 * nCr(j - 1, k - 1);
          } else if (a[0] == i) {
            int loc = 1;
            while (a[loc] == 0) {
              loc++;
              if (loc == keta) break;
            }
            if (loc == keta) continue;
            for (int l = (1); l < (10); l++) {
              if (l < a[loc]) {
                ans += 9 * nCr(j - 1, k - 1);
              } else if (l == a[loc]) {
                ans += 9 * nCr(j - 2, k - 1);
                ;
                int loc2 = loc + 1;
                while (a[loc2] == 0) {
                  loc2++;
                  if (loc2 == keta) break;
                }
                if (loc2 == keta) continue;
                for (int m = (1); m < (10); m++) {
                  if (m < a[loc2]) {
                    ans += keta - loc2;
                  } else if (m == a[loc2]) {
                    ans += keta - loc2;
                  }
                }
              };
            }
          }
        };
      }
    }
  }
  cout << ans << endl;
}
