#include <bits/stdc++.h>
using namespace std;
bool vis[120][4][2];
long long int dp[120][4][2];
string s;
long long int calc(long long int now, long long int leftK, int maxFlag) {
  if (vis[now][leftK][maxFlag]) return dp[now][leftK][maxFlag];
  vis[now][leftK][maxFlag] = 1;
  if (leftK == 0) {
    return dp[now][leftK][maxFlag] = 1;
  }
  if (now >= s.size()) return dp[now][leftK][maxFlag] = 0;
  long long int rtn = 0;
  if (maxFlag) {
    if (s.at(now) == '0')
      rtn += calc(now + 1, leftK, 1);
    else
      rtn += calc(now + 1, leftK, 0);
    rtn += calc(now + 1, leftK - 1, 1);
    rtn += (s.at(now) - '1') * calc(now + 1, leftK - 1, 0);
  } else {
    rtn += calc(now + 1, leftK, 0);
    rtn += 9 * calc(now + 1, leftK - 1, 0);
  }
  return dp[now][leftK][maxFlag] = rtn;
}
signed main() {
  long long int k;
  cin >> s >> k;
  cout << calc(0, k, 1);
  return 0;
}
