#include <bits/stdc++.h>
using namespace std;
int ctoi(const char c) {
  switch (c) {
    case '0':
      return 0;
    case '1':
      return 1;
    case '2':
      return 2;
    case '3':
      return 3;
    case '4':
      return 4;
    case '5':
      return 5;
    case '6':
      return 6;
    case '7':
      return 7;
    case '8':
      return 8;
    case '9':
      return 9;
    default:
      return -1;
  }
}
char itoc(const int c) {
  switch (c) {
    case 0:
      return '0';
    case 1:
      return '1';
    case 2:
      return '2';
    case 3:
      return '3';
    case 4:
      return '4';
    case 5:
      return '5';
    case 6:
      return '6';
    case 7:
      return '7';
    case 8:
      return '8';
    case 9:
      return '9';
  }
}
int check(string M, string L, int s) {
  for (int i = 0; i < s; i++) {
    if (ctoi(L[i]) > ctoi(M[i])) {
      return 1;
    }
    if (ctoi(L[i]) < ctoi(M[i])) {
      return 0;
    }
  }
  return 1;
}
int main() {
  string S;
  cin >> S;
  int K;
  cin >> K;
  int s = S.size();
  if (s - K < 0) {
    cout << 0 << endl;
    return 0;
  }
  string A = "";
  for (int i = 0; i < s; i++) {
    A += "0";
  }
  long long ans = 0;
  if (K == 1) {
    for (int i = 0; i < s; i++) {
      for (int a = 1; a <= 9; a++) {
        string B = A;
        B[i] = itoc(a);
        ans += check(S, B, s);
      }
    }
    cout << ans << endl;
    return 0;
  }
  if (K == 2) {
    for (int i = 0; i < s - 1; i++) {
      for (int a = 1; a <= 9; a++) {
        for (int j = i; j < s; j++) {
          for (int b = 1; b <= 9; b++) {
            string B = A;
            B[i] = itoc(a);
            B[j] = itoc(b);
            ans += check(S, B, s);
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
  }
  if (K == 3) {
    for (int i = 0; i < s - 2; i++) {
      for (int a = 1; a <= 9; a++) {
        for (int j = i; j < s - 1; j++) {
          for (int b = 1; b <= 9; b++) {
            for (int l = j; l < s; l++) {
              for (int c = 0; c <= 9; c++) {
                string B = A;
                B[i] = itoc(a);
                B[j] = itoc(b);
                B[l] = itoc(c);
                ans += check(S, B, s);
              }
            }
          }
        }
      }
    }
    cout << ans << endl;
    return 0;
  }
}
