#include <bits/stdc++.h>
using namespace std;
const long long int LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
int main() {
  string N;
  cin >> N;
  int K;
  cin >> K;
  vector<int> dp(K + 1, 0);
  int b = 0;
  for (int ni = 0; ni < ((int)(N).size()); ++ni) {
    int x = N[ni] - '0';
    vector<int> dp2(K + 1, 0);
    for (int k = 0; k < (K + 1); ++k) {
      dp2[k] += dp[k];
    }
    for (int k = 0; k < (K); ++k) {
      dp2[k + 1] += dp[k] * 9;
    }
    if (b <= K) {
      for (int n = 0; n < (10); ++n) {
        if (n < x) {
          if (n == 0) {
            dp2[b] += 1;
          } else if (b + 1 <= K) {
            dp2[b + 1] += 1;
          }
        }
      }
      if (x > 0) {
        b++;
      }
    }
    dp = dp2;
  }
  int ans = dp[K];
  if (b <= K) {
    ans++;
  }
  cout << ans << endl;
  return 0;
}
