#include <bits/stdc++.h>
using namespace std;
string S;
long long K;
long long dp[200][2][5];
int main() {
  cin >> S >> K;
  dp[0][1][0] = 1;
  for (long long i = 0; i < S.size(); i++) {
    long long num = S[i] - '0';
    for (long long k = 0; k <= K; k++) {
      dp[i + 1][0][k] += dp[i][0][k];
    }
    for (long long n = 1; n < 10; n++) {
      for (long long k = 0; k <= K; k++) {
        dp[i + 1][0][k + 1] += dp[i][0][k];
      }
    }
    for (long long k = 0; k <= K; k++) {
      dp[i + 1][0][k] += dp[i][1][k];
    }
    for (long long n = 1; n < num; n++) {
      for (long long k = 0; k <= K; k++) {
        dp[i + 1][0][k + 1] += dp[i][1][k];
      }
    }
    for (long long k = 0; k <= K; k++) {
      dp[i + 1][1][k + 1] += dp[i][1][k];
    }
  }
  cout << dp[S.size()][0][K] + dp[S.size()][1][K] << endl;
}
