#include <bits/stdc++.h>
using namespace std;
const int N = 100005;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  cout << fixed << setprecision(6);
  string n;
  int k;
  long long dp[101][2][5];
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  cin >> n >> k;
  for (long long i = (long long)(0); i < (long long)(n.size()); ++i) {
    int a = n[i] - '0';
    for (long long j = (long long)(0); j < (long long)(k + 1); ++j) {
      for (long long smaller = (long long)(0); smaller < (long long)(2);
           ++smaller) {
        for (long long d = (long long)(0);
             d < (long long)((smaller ? 9 : a) + 1); ++d) {
          if (d != 0)
            dp[i + 1][smaller || (d < a)][j + 1] += dp[i][smaller][k];
          else
            dp[i + 1][smaller || (d < a)][k] += dp[i][smaller][k];
        }
      }
    }
  }
  cout << dp[n.size()][0][k] + dp[n.size()][1][k] << "\n";
  ;
  return 0;
}
