#include <bits/stdc++.h>
using namespace std;
typedef bool BL;
typedef char SB;
typedef unsigned char UB;
typedef short SW;
typedef unsigned short UW;
typedef long SDW;
typedef unsigned long UDW;
typedef long long SLL;
typedef unsigned long long ULL;
typedef char CH;
typedef float R32;
typedef double R64;
const ULL mod = 1e9 + 7;
const ULL inf = 0x7fffffff;
const ULL infLL = 0x7fffffffffffffffLL;
const UDW maxN = 1e6 + 7;
string N;
SLL len;
SDW K;
SLL ans;
void input() {
  cin >> N >> K;
  len = N.size();
}
void do1() {
  SDW a = N[0] - '0';
  SLL posA = len;
  ans += a * posA;
}
void do2() {
  SDW a = N[0] - '0';
  SLL posA = len;
  SDW b = 0;
  SLL posB = 1;
  for (register SDW i = (1); i <= (len - 1); ++i) {
    if (N[i] != '0') {
      b = N[i] - '0';
      posB = len - i;
      break;
    }
  }
  ans += 9 * (posA - 1) * (posA - 2) * 9 / 2;
  ans += (a - 1) * (posA - 1) * 9;
  ans += b;
  ans += (posB - 1) * 9;
}
void do3() {
  SDW a = N[0] - '0';
  SLL posA = len;
  SDW b = 0;
  SLL posB = 1;
  for (register SDW i = (1); i <= (len - 1); ++i) {
    if (N[i] != '0') {
      b = N[i] - '0';
      posB = len - i;
      break;
    }
  }
  SDW c = 0;
  SLL posC = 1;
  for (register SDW i = (len - posB + 1); i <= (len - 1); ++i) {
    if (N[i] != '0') {
      c = N[i] - '0';
      posC = len - i;
      break;
    }
  }
  ans += 9 * 9 * 9 * (posA - 1) * (posA - 2) * (posA - 3) / 6;
  ans += (a - 1) * 9 * 9 * (posA - 1) * (posA - 2) / 2;
  ans += 9 * 9 * (posB - 1) * (posB - 2) / 2;
  ans += (b - 1) * (posB - 1) * 9;
  ans += c;
  ans += (posC - 1) * 9;
}
void solve() {
  switch (K) {
    case 1: {
      do1();
      break;
    }
    case 2: {
      do2();
      break;
    }
    case 3: {
      do3();
      break;
    }
    default: {
      assert(false);
    }
  }
}
void output() { cout << ans << endl; }
int main() {
  input();
  solve();
  output();
  return 0;
}
