#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vs = vector<str>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vpii = vector<pii>;
using vpll = vector<pll>;
const ld PI = (acos(-1));
const ll MOD = 1000000007;
struct __io_async {
  __io_async() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(20);
  };
};
int n_len;
int k;
ll dp[100 + 1][100 + 1];
int main() {
  str n;
  cin >> n >> k;
  n_len = n.length();
  for (ll i = ((ll)0); i < ((ll)n_len + 1); ++i) {
    for (ll j = ((ll)0); j < ((ll)k + 1); ++j) {
      if (j > i) continue;
      if (j == 0) dp[i][j] = 1;
      if (i + 1 <= n_len) {
        dp[i + 1][j] += dp[i][j];
        if (j + 1 <= k) {
          dp[i + 1][j + 1] +=
              (i == j ? (n[i] - '0') + (dp[i][j] - 1) * 9 : dp[i][j] * 9);
        }
      }
    }
  }
  cout << dp[n_len][k] << "\n";
  return 0;
}
