#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  long long m;
  cin >> m;
  long long ch[102][4][2];
  ch[0][0][0] = 1;
  for (long long i = 0; i < s.size(); i++) {
    long long now = s[i] - '0';
    for (long long j = 0; j < 10; j++) {
      for (long long k = 0; k < 4; k++) {
        if (j == 0) {
          if (now == 0) {
            ch[i + 1][k][0] += ch[i][k][0];
            ch[i + 1][k][1] += ch[i][k][1];
          } else {
            ch[i + 1][k][1] += ch[i][k][0];
            ch[i + 1][k][1] += ch[i][k][1];
          }
        } else {
          if (j < now) {
            ch[i + 1][k + 1][1] += ch[i][k][0];
            ch[i + 1][k + 1][1] += ch[i][k][1];
          } else if (j == now) {
            ch[i + 1][k + 1][0] += ch[i][k][0];
            ch[i + 1][k + 1][1] += ch[i][k][1];
          } else {
            ch[i + 1][k + 1][1] += ch[i][k][1];
          }
        }
      }
    }
  }
  cout << ch[s.size()][m][0] + ch[s.size()][m][1];
  return 0;
}
