#include <bits/stdc++.h>
using namespace std;
template <class T1, class T2>
inline bool minimize(T1& a, T2 b) {
  return b < a && (a = b, 1);
}
template <class T1, class T2>
inline bool maximize(T1& a, T2 b) {
  return a < b && (a = b, 1);
}
template <class T, class V>
istream& operator>>(istream& ist, pair<T, V>& p) {
  return ist >> p.first >> p.second;
}
template <class T>
ostream& operator<<(ostream& ost, pair<T, T>& p) {
  return ost << p.first << ", " << p.second;
}
template <class T>
istream& operator>>(istream& ist, vector<T>& vs) {
  for (auto& e : vs) ist >> e;
  return ist;
}
int const inf = INT_MAX / 2;
string S;
int K;
long long dp[101][4][2];
long long rec(int idx, int k, bool upmost) {
  long long& ret = dp[idx][k][upmost];
  if (ret >= 0) return ret;
  if (idx == S.size()) {
    return k == 0;
  }
  ret = 0;
  if (upmost) {
    if (idx > 0) {
      ret += rec(idx + 1, k, S[idx] == 0);
    } else {
      ret += rec(idx + 1, k, 0);
    }
    if (k) {
      for (int d = 1; d < (int)S[idx]; d++) {
        ret += rec(idx + 1, k - 1, 0);
      }
      ret += rec(idx + 1, k - 1, 1);
    }
  } else {
    ret += rec(idx + 1, k, 0);
    for (int d = 1; d < (int)10; d++) {
      if (k == 0) {
        continue;
      }
      ret += rec(idx + 1, k - 1, 0);
    }
  }
  return ret;
}
int main() {
  cin >> S >> K;
  for (int i = 0; i < (int)S.size(); i++) S[i] -= '0';
  for (int i = 0; i < (int)101; i++)
    for (int j = 0; j < (int)4; j++)
      for (int k = 0; k < (int)2; k++) dp[i][j][k] = -1;
  cout << rec(0, K, 1) << "\n";
}
