#include <bits/stdc++.h>
using namespace std;
const long long MX = 1e6;
const long long inf = 1e13;
const long long mod = 1e9 + 7;
long long dp[102][2][4];
signed main() {
  string s;
  long long k;
  cin >> s >> k;
  long long n = s.length();
  dp[0][1][1] = (s[0] > 0);
  dp[0][1][0] = 0;
  dp[0][0][1] = max(0, s[0] - '1');
  dp[0][0][0] = 1;
  for (long long i = (1); i < (n); ++i) {
    if (s[i] == 0) {
      dp[i][1][0] = dp[i - 1][1][0];
      dp[i][1][1] = dp[i - 1][1][1];
      dp[i][1][2] = dp[i - 1][1][2];
      dp[i][1][3] = dp[i - 1][1][3];
      dp[i][0][0] = dp[i - 1][0][0];
      dp[i][0][1] = dp[i - 1][0][1] + dp[i - 1][0][0] * 9;
      dp[i][0][2] = dp[i - 1][0][2] + dp[i - 1][0][1] * 9;
      dp[i][0][3] = dp[i - 1][0][3] + dp[i - 1][0][2] * 9;
    } else {
      dp[i][1][0] = 0;
      dp[i][1][1] = dp[i - 1][1][0];
      dp[i][1][2] = dp[i - 1][1][1];
      dp[i][1][3] = dp[i - 1][1][2];
      dp[i][0][0] = dp[i - 1][0][0] + dp[i - 1][1][0];
      dp[i][0][1] = dp[i - 1][0][1] + dp[i - 1][0][0] * 9 + dp[i - 1][1][1] +
                    dp[i - 1][1][0] * (s[i] - '1');
      dp[i][0][2] = dp[i - 1][0][2] + dp[i - 1][0][1] * 9 + dp[i - 1][1][2] +
                    dp[i - 1][1][1] * (s[i] - '1');
      dp[i][0][3] = dp[i - 1][0][3] + dp[i - 1][0][2] * 9 + dp[i - 1][1][3] +
                    dp[i - 1][1][2] * (s[i] - '1');
    }
  }
  cout << dp[n - 1][0][k] + dp[n - 1][1][k] << endl;
  return 0;
}
