#include <bits/stdc++.h>
using namespace std;
typedef priority_queue<long long, vector<long long>, greater<long long>> spqll;
typedef priority_queue<long long, vector<long long>, less<long long>> bpqll;
long long INF = 1e9;
long long NIL = -1;
long long MOD = 1000000007;
long long LINF = 1e18;
long double EPS = 1e-9;
long double PI = M_PI;
vector<long long> dx = {1, 0, -1, 0, 1, -1, -1, 1};
vector<long long> dy = {0, 1, 0, -1, 1, 1, -1, -1};
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long lcm(long long a, long long b) { return a / gcd(a, b) * b; }
void yes() { cout << "Yes" << endl; }
void no() { cout << "No" << endl; }
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  long long k;
  cin >> s >> k;
  long long n = (long long)s.size();
  vector<vector<long long>> dp(n, vector<long long>(4, 1));
  dp[0][1] = (s[0] - '0');
  dp[0][2] = 0;
  dp[0][3] = 0;
  for (long long i = 1; i < n; i++) {
    for (long long j = 0; j < (long long)(4); j++) {
      if (j != 0) {
        if (i + 1 == j) {
          dp[i][j] = (dp[i - 1][j - 1] - 1) * 9 + (s[i] - '0');
        } else {
          dp[i][j] = dp[i - 1][j - 1] * 9 + dp[i - 1][j];
        }
      }
    }
  }
  cout << dp[n - 1][k] << endl;
  return 0;
}
