#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)1e6 + 5;
long long dp[2][105][4];
int main() {
  string n;
  cin >> n;
  int k;
  cin >> k;
  int l = n.length();
  dp[0][0][0] = 1ll;
  for (int i = 0; i < l; i++) {
    for (int j = (int)(0); j <= (int)(k); j++)
      for (int d = (int)(0); d <= (int)(n[i] - '0'); d++)
        dp[d < n[i] - '0'][i + 1][d == 0 ? j : j + 1] += dp[0][i][j];
    for (int j = (int)(0); j <= (int)(k); j++)
      for (int d = (int)(0); d <= (int)(9); d++)
        dp[1][i + 1][d == 0 ? j : j + 1] += dp[1][i][j];
  }
  cout << dp[0][l][k] + dp[1][l][k] << endl;
}
