#include <bits/stdc++.h>
using namespace std;
string s;
int n, k;
long long dp[1010][5][2];
long long dfs(int i = 0, int x = 0, bool l = true) {
  if (i == n) return x == k;
  long long &cc = dp[i][x][l];
  if (~cc) return cc;
  long long ans = 0;
  int u = l ? s[i] - '0' : 9;
  for (int d = 0; d < u + 1; d++) {
    ans += dfs(i + 1, x + (d != 0), l && d == u);
  }
  return cc = ans;
}
int main() {
  cin >> s;
  cin >> k;
  n = s.size();
  memset(dp, -1, sizeof(dp));
  cout << dfs() << endl;
  return 0;
}
