#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
const double eps = 1e-15;
const double pi = acos(-1);
const int INF = 0x3f3f3f3f;
long long read() {
  long long c = getchar(), Nig = 1, x = 0;
  while (!isdigit(c) && c != '-') c = getchar();
  if (c == '-') Nig = -1, c = getchar();
  while (isdigit(c)) x = ((x << 1) + (x << 3)) + (c ^ '0'), c = getchar();
  return Nig * x;
}
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
long long dp[maxn][5];
int main() {
  string s;
  int m;
  cin >> s;
  cin >> m;
  s = " " + s;
  dp[1][0] = 1;
  dp[1][1] = (s[1] - '0');
  dp[1][2] = 0;
  dp[1][3] = 0;
  int n = s.size();
  for (int i = 2; i < n; i++) {
    int k = s[i] - '0';
    int p = s[i - 1] - '0';
    dp[i][0] = dp[i - 1][0];
    dp[i][1] = dp[i - 1][0] * 9 + dp[i - 1][1] * dp[i][0];
    if (dp[i - 1][1] > 0) {
      if (i > 2)
        dp[i][2] = dp[i - 1][2] + (dp[i - 1][1]) * 9;
      else
        dp[i][2] = dp[i - 1][2] + (dp[i - 1][1] - 1) * 9 + k;
    }
    if (dp[i - 1][2] > 0) {
      if (i > 3)
        dp[i][3] = dp[i - 1][3] + (dp[i - 1][2]) * 9;
      else
        dp[i][3] = dp[i - 1][3] + (dp[i - 1][2] - 1) * 9 + k;
    }
  }
  cout << dp[n - 1][m] << '\n';
  return 0;
}
