#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5 + 1;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  string second;
  int k;
  cin >> second >> k;
  int n = second.length();
  long long dp[101][2][4] = {};
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 2; j++) {
      for (int l = 0; l <= k; l++) {
        int dig = j ? 9 : (second[i] - '0');
        for (int d = 0; d <= dig; d++) {
          dp[i + 1][j || d < dig][l + (d != 0)] += dp[i][j][l];
        }
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k];
  return 0;
}
