#include <bits/stdc++.h>
using namespace std;
long long n;
string num;
long long k;
long long dp[202][2][10];
long long C[202][202];
signed main() {
  C[0][0] = 1;
  for (long long i = 1; i <= 122; i++) {
    C[i][0] = 1;
    C[i][1] = i;
  }
  for (long long i = 2; i <= 122; i++) {
    for (long long j = 2; j <= min(3ll, i); j++) {
      C[i][j] = C[i - 1][j] + C[i - 1][j - 1];
    }
  }
  ios::sync_with_stdio(false);
  cin >> num >> k;
  n = num.length();
  memset(dp, 0, sizeof dp);
  dp[0][0][0] = 1;
  for (long long i = 1; i <= n; i++) {
    for (long long op = 0; op < 2; op++) {
      for (long long j = 0; j < 3; j++) {
        if (dp[i - 1][op][j] == -1) continue;
        for (long long add = 0; add <= 9; add++) {
          if (op == 0) {
            if (add < num[i - 1] - '0') {
              dp[i][1][j + (add > 0)] += dp[i - 1][op][j];
            } else if (add == num[i - 1] - '0') {
              dp[i][0][j + (add > 0)] += dp[i - 1][op][j];
            }
          } else {
            dp[i][1][j + (add > 0)] += dp[i - 1][op][j];
          }
        }
      }
    }
  }
  cout << dp[n][1][k] + dp[n][0][k] << endl;
  return 0;
}
