#include <bits/stdc++.h>
using namespace std;
string N;
int K;
vector<int> v;
long long dp[105][2][4];
int main() {
  cin >> N;
  cin >> K;
  for (int i = 0; i < N.size(); i++) {
    v.push_back(N[i] - '0');
  }
  dp[0][0][0] = 1;
  for (int i = 0; i < N.size(); i++) {
    for (int smaller = 0; smaller < 2; smaller++) {
      for (int k = 0; k <= K; k++) {
        for (int x = 0; x <= (smaller ? 9 : v[i]); x++) {
          dp[i + 1][smaller || x < v[i]][k + (x != 0)] += dp[i][smaller][k];
        }
      }
    }
  }
  long long ans = dp[N.size()][0][K] + dp[N.size()][1][K];
  cout << ans << endl;
}
