#include <bits/stdc++.h>
using namespace std;
string s;
long long dp[200][5];
int ways(int n, int r) {
  if (n < r) return 0;
  int ret = 1, mul = 1;
  for (int i = 0; i < r; ++i) ret *= (n - i), ret /= i + 1, mul *= 9;
  return ret * mul;
}
long long solve(int x, int k) {
  if (x == (int)s.size()) return (k == 0);
  if (k == 0) return 1;
  long long &ret = dp[x][k];
  if (ret != -1) return ret;
  ret = 0;
  for (int i = 1; i <= 9; ++i) {
    int d = s[x] - '0';
    if (i < d)
      ret += ways((int)s.size() - x - 1, k - 1);
    else if (i == d)
      ret += solve(x + 1, k - 1);
  }
  ret += ways((int)s.size() - x - 1, k);
  return ret;
}
int main() {
  ios::sync_with_stdio(false);
  cout.tie(nullptr);
  cin.tie(nullptr);
  memset(dp, -1, sizeof dp);
  int k;
  cin >> s >> k;
  cout << solve(0, k) << '\n';
}
