#include <bits/stdc++.h>
using namespace std;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
const int MAXN = 100000;
const int MAXE = 100000;
const int MAXV = 10000;
const int INF = 2e9;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = s.size();
  long long dp[n + 1][n + 1][2];
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      for (int k = 0; k < 2; k++) {
        dp[i][j][k] = 0;
      }
    }
  }
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j <= i; j++) {
      for (int h = 0; h < 2; h++) {
        for (int d = 0; d <= (h == 1 ? 9 : (int)(s[i] - '0')); d++) {
          dp[i + 1][j + (d > 0 ? 1 : 0)][h || (d < (int)(s[i] - '0'))] +=
              dp[i][j][h];
        }
      }
    }
  }
  cout << dp[n][k][0] + dp[n][k][1] << endl;
  return 0;
}
