#include <bits/stdc++.h>
using namespace std;
string s;
int dp[203][4];
int g(int len, int k) {
  if (len < k)
    return 0;
  else if (k == 1)
    return len * 9;
  else if (k == 0)
    return 1;
  else if (k == 2)
    return len * (len - 1) / 2 * 9 * 9;
  else
    return len * (len - 1) * (len - 2) / 6 * 9 * 9 * 9;
}
int f(int x, int k) {
  if (k == 0)
    return 1;
  else if (k == 0 && x == s.size())
    return 1;
  else if (x == s.size() && k)
    return 0;
  else if (dp[x][k])
    return dp[x][k];
  else {
    dp[x][k] += f(x + 1, k - 1);
    for (int i = 1; i < s[x] - '0'; i++)
      dp[x][k] += g(s.size() - (x + 1), k - 1);
    dp[x][k] += g(s.size() - (x + 1), k);
    return dp[x][k];
  }
}
int main() {
  cin >> s;
  int k;
  cin >> k;
  cout << f(0, k) << "\n";
}
