#include <bits/stdc++.h>
using namespace std;
const long long int LINF = 2000000000000000000ll;
const int INF = 1000000100;
const long long int MOD = 1e9 + 7;
int main() {
  string n;
  int k;
  cin >> n >> k;
  int l = n.length();
  const int MAX = l + 5;
  vector<vector<long long int> > dp(MAX, vector<long long int>(4, 0));
  dp[1][0] = 1;
  dp[1][1] = 9;
  for (int i = 2; i < (MAX); ++i) {
    dp[i][0] = 1;
    for (int j = 1; j < (4); ++j) {
      dp[i][j] = dp[i - 1][j - 1] * 9 + dp[i - 1][j];
    }
  }
  long long int ans = 0;
  for (int i = 0; i < (k); ++i) {
    int num = n[i] - '0';
    int digit = l - i - 1;
    if (digit < 0) continue;
    if (k - i == 1)
      ans += dp[digit][k - i] + num;
    else
      ans += dp[digit][k - i] + dp[digit][k - i - 1] * (num - 1);
  }
  cout << ans << endl;
  return 0;
}
