#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
int dddx[] = {1, -1, 0, 0, 1, 1, -1, -1};
int dddy[] = {0, 0, 1, -1, 1, -1, 1, -1};
string s;
int k;
int dp[101][3][9];
int vis[101][3][9];
long long int solve(int pos, bool can, int kk) {
  if (pos == s.size()) {
    return (kk == k ? 1 : 0);
  }
  if (kk > k) return 0;
  int atual = s[pos] - '0';
  long long int ans = 0;
  for (int i = 0; i <= 9; i++) {
    if (can or i <= atual) {
      bool pode = can;
      if (i < atual) pode = true;
      ans += solve(pos + 1, pode, i > 0 ? (kk + 1) : kk);
    }
  }
  vis[pos][can][kk] = 1;
  return dp[pos][can][kk] = ans;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cin >> s;
  cin >> k;
  cout << solve(0, 0, 0) << "\n";
  return 0;
}
