#include <bits/stdc++.h>
using namespace std;
const long long mod = 1000000007;
const long long INF = (long long)1000000007 * 1000000007;
const long double eps = 1e-8;
const long double pi = acos(-1.0);
string n;
int k;
long long dp[110][4][2];
void solve() {
  cin >> n;
  cin >> k;
  int m = n.length();
  dp[0][0][0] = 1;
  for (int i = 0; i < m; i++) {
    long long s = n[i] - '0';
    for (int l = 0; l < k; l++) {
      dp[i + 1][l + 1][1] += (s - (long long)1) * dp[i][l][0];
      dp[i + 1][l + 1][1] += (long long)9 * dp[i][l][1];
      if (s != 0) dp[i + 1][l + 1][0] += (long long)dp[i][l][0];
    }
    for (int l = 0; l < k + 1; l++) {
      if (s == 0) {
        dp[i + 1][l][0] += dp[i][l][0];
        dp[i + 1][l][1] += dp[i][l][1];
      } else {
        dp[i + 1][l][1] += dp[i][l][0] + dp[i][l][1];
      }
    }
  }
  for (int i = 0; i < m + 1; i++) {
    for (int l = 0; l < k + 1; l++) {
      for (int flag = 0; flag < 2; flag++) {
      }
    }
  }
  cout << dp[m][k][0] + dp[m][k][1] << endl;
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(50);
  solve();
}
