#include <bits/stdc++.h>
using namespace std;
const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI = 3.14159265358979323;
long long int K, M, x, y, res = 0, tmp = 0, dp[200][5][2] = {};
pair<long long int, long long int> ba[200200];
string N;
int main() {
  cout << fixed << setprecision(18);
  cin >> N >> K;
  dp[0][1][0] = 1;
  dp[0][1][1] = N[0] - '1';
  for (long long int i = 1; i < N.size(); i++) {
    dp[i][1][1] += 9;
    if (N[i] == '0') {
      dp[i][1][0] += dp[i - 1][1][0];
      dp[i][1][1] += dp[i - 1][1][1];
      dp[i][2][0] += dp[i - 1][2][0];
      dp[i][2][1] += dp[i - 1][2][1];
      dp[i][3][0] += dp[i - 1][3][0];
      dp[i][3][1] += dp[i - 1][3][1];
      dp[i][2][1] += 9 * dp[i - 1][1][1];
      dp[i][3][1] += 9 * dp[i - 1][2][1];
    } else {
      dp[i][1][1] += dp[i - 1][1][0];
      dp[i][1][1] += dp[i - 1][1][1];
      dp[i][2][1] += dp[i - 1][2][0];
      dp[i][2][1] += dp[i - 1][2][1];
      dp[i][3][1] += dp[i - 1][3][0];
      dp[i][3][1] += dp[i - 1][3][1];
      dp[i][2][0] += dp[i - 1][1][0];
      dp[i][3][0] += dp[i - 1][2][0];
      dp[i][2][0] += (N[i] - '1') * dp[i - 1][1][0];
      dp[i][3][0] += (N[i] - '1') * dp[i - 1][2][0];
      dp[i][2][1] += 9 * dp[i - 1][1][1];
      dp[i][3][1] += 9 * dp[i - 1][2][1];
    }
  }
  cout << dp[N.size() - 1][K][1] + dp[N.size() - 1][K][0] << endl;
}
