#include <bits/stdc++.h>
using namespace std;
vector<vector<vector<long long> > > dp;
signed main(void) {
  string s;
  long long K;
  cin >> s >> K;
  long long digit = int((s).size());
  dp[0][0][0] = 1;
  for (int i; i < (digit); i++)
    for (int j; j < (4); j++)
      for (int k; k < (2); k++) {
        long long nd = s[i] - '0';
        for (int d; d < (10); d++) {
          long long ni = i + 1, nj = j, nk = k;
          if (d != 0) nj++;
          if (nj > K) continue;
          if (k == 0) {
            if (d > nd) continue;
            if (d < nd) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
  long long ans = dp[digit][K][0] + dp[digit][K][1];
  cout << ans << endl;
  return 0;
}
