#include <bits/stdc++.h>
const int maxn = 2e5 + 10;
const int mod = 1e9 + 7;
using namespace std;
string s;
struct node {
  long long xy, dy;
  node() { xy = 0, dy = 0; }
};
node dp[105][5];
int main() {
  int k;
  cin >> s >> k;
  int len = s.size();
  s = ' ' + s;
  dp[len + 1][0].dy = 1;
  for (int i = len; i >= 1; i--)
    for (int j = 1; j <= 3; j++) {
      dp[i][j].dy = dp[i + 1][j].dy + dp[i + 1][j - 1].dy * 9;
      dp[i][j].xy = (dp[i + 1][j - 1].dy - dp[i + 1][j - 1].xy) * (s[i] - '0') +
                    dp[i + 1][j - 1].xy * 9 + dp[i + 1][j].dy;
    }
  cout << dp[1][k].xy - dp[2][k].dy;
  return 0;
}
