#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
const int mex = 5000001;
int main() {
  long long int dp[4][105], fact[101];
  fact[0] = 1;
  for (int i = 1; i < 101; i++) fact[i] = fact[i - 1] * i;
  for (int i = 0; i < 4; i++)
    for (int j = 0; j < 101; j++) {
      if (j >= i) {
        if (i == 1)
          dp[i][j] = j;
        else if (i == 2)
          dp[i][j] = (j * (j - 1)) / 2;
        else
          dp[i][j] = (j * (j - 1) * (j - 2)) / 6;
      } else
        dp[i][j] = 0;
      for (int k = 1; k < i + 1; k++) dp[i][j] *= 9;
    }
  for (int j = 0; j < 101; j++) dp[0][j] = 1;
  string s;
  cin >> s;
  int k;
  cin >> k;
  int y = k;
  int n = s.size();
  long long int ans = 0, cnt = 0;
  for (int i = 0; i < n; i++) {
    long long int h = (s[i] - '0' - 1);
    if (h >= 0) cnt++;
    if (h > 0) ans = ans + h * dp[k - 1][n - i - 1];
    ans += dp[k][n - i - 1];
    k--;
    if (k == 0) break;
  }
  int fg = 0;
  if (cnt == y) fg = 1;
  cout << ans + fg;
}
