#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e18 + 7;
long long mypow(long long base, long long exp) {
  long long res = 1;
  while (exp) {
    if (exp & 1) res = (res * base) % mod;
    exp >>= 1, base = (base * base) % mod;
  }
  return res;
}
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long mult(long long a, long long b) { return ((a) * (b)); }
long long add(long long a, long long b) { return (a + b); }
long long sub(long long a, long long b) { return (a - b); }
const long long inf = 1e18;
const int nax = 110;
long long n, k;
string s;
long long dp[nax][4][2];
long long solve(long long idx, bool allowed, long long rqd) {
  if (rqd < 0) return 0;
  if (idx >= n) {
    if (rqd == 0)
      return 1;
    else
      return 0;
  }
  if (dp[idx][rqd][allowed] != -1) return dp[idx][rqd][allowed];
  long long ans = 0;
  if (!allowed) {
    if ((s[idx] - '0' - 1) >= 0) {
      ans = mult(s[idx] - '0' - 1, solve(idx + 1, 1, rqd - 1));
    }
    if (s[idx] != '0') {
      ans = add(ans, solve(idx + 1, 0, rqd - 1));
    }
    ans = add(ans, solve(idx + 1, 1, rqd));
  } else {
    ans = add(mult(9, solve(idx + 1, 1, rqd - 1)), solve(idx + 1, 1, rqd));
  }
  dp[idx][rqd][allowed] = ans;
  return ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> s >> k;
  n = s.length();
  long long ans = 0;
  for (long long i = 0; i < nax; i++) {
    for (long long j = 0; j < 4; j++) {
      for (long long k = 0; k < 2; k++) {
        dp[i][j][k] = -1;
      }
    }
  }
  ans = solve(0, 0, k);
  cout << ans;
  return 0;
}
