#include <bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;
int main() {
  string n;
  cin >> n;
  int sz = n.size();
  int k;
  cin >> k;
  ll dp[105][4][2];
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < k + 1; j++)
      for (int l = 0; l < 2; l++) {
        dp[i][j][l] = 0;
      }
  dp[0][0][0] = 1;
  for (int i = 0; i < sz; i++)
    for (int j = 0; j < k + 1; j++)
      for (int l = 0; l < 2; l++) {
        int nsz = n[sz - i - 1] - '0';
        for (int dig = 0; dig < 10; dig++) {
          if (dig == 0 && nsz > 0) {
            dp[i + 1][j][0] += dp[i][j][l];
          } else if (dig == 0 && nsz == 0) {
            dp[i + 1][j][l] += dp[i][j][l];
          } else if (nsz > dig && dig != 0 && j + 1 <= k) {
            dp[i + 1][j + 1][0] += dp[i][j][l];
          } else if (nsz == dig && dig != 0 && j + 1 <= k) {
            dp[i + 1][j + 1][l] += dp[i][j][l];
          } else if (nsz < dig && dig != 0 && j + 1 <= k) {
            dp[i + 1][j + 1][1] += dp[i][j][l];
          }
        }
      }
  cout << dp[sz][k][0] << endl;
  return 0;
}
