#include <bits/stdc++.h>
using namespace std;
string s;
int t[101];
int n, k;
int main() {
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++) t[i] = s[i] - '0';
  cin >> k;
  long long dp[n][k + 1], dp2[n + 1][k + 1];
  fill(dp[0], dp[n + 1], 0);
  fill(dp2[0], dp2[n + 1], 0);
  dp[0][0] = 1;
  dp[0][1] = t[0] - 1;
  dp2[0][1] = 1;
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j <= k; j++) {
      for (int m = 0, y = 0; m < 10; m++, y = 1) {
        if (j == k && y == 1) continue;
        if (t[i + 1] > m) {
          dp[i + 1][j + y] += dp[i][j];
        } else if (t[i + 1] == m) {
          dp[i + 1][j + y] += dp[i][j];
          dp2[i + 1][j + y] = dp2[i][j];
        } else if (t[i + 1] < m) {
          dp[i + 1][j + y] += dp[i][j];
          dp2[i + 1][j + y] = dp2[i][j];
        }
      }
    }
  }
  cout << dp[n - 1][k] + dp2[n - 1][k] << endl;
}
