#include <bits/stdc++.h>
using namespace std;
string a;
int k;
long long dp[102][2][100000];
int solve(int index, int smaller, int val) {
  if (val > k) {
    return 0;
  }
  if (index == a.length()) {
    if (val == k) {
      return 1;
    }
    return 0;
  }
  if (dp[index][smaller][val] != -1) {
    return dp[index][smaller][val];
  } else {
    long long cnt = 0;
    int ret;
    if (smaller) {
      ret = 9;
    } else {
      ret = a[index] - '0';
    }
    for (int i = 0; i <= ret; i++) {
      bool ns = smaller;
      if (!smaller) {
        if (i < a[i] - '0') {
          ns = 1;
        } else {
          ns = 0;
        }
      }
      cnt += solve(index + 1, ns, val + (i != 0 ? 1 : 0));
    }
    return dp[index][smaller][val] = cnt;
  }
}
int main() {
  cin >> a >> k;
  memset(dp, -1, sizeof(dp));
  cout << solve(0, 0, 0);
}
