#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  char aa = s.at(0);
  int a;
  if (aa == '1') a = 1;
  if (aa == '2') a = 2;
  if (aa == '3') a = 3;
  if (aa == '4') a = 4;
  if (aa == '5') a = 5;
  if (aa == '6') a = 6;
  if (aa == '7') a = 7;
  if (aa == '8') a = 8;
  if (aa == '9') a = 9;
  long long out = 0;
  for (int i = 1; i < s.size(); i++) {
    if (k == 1) out += 9;
    if (k == 2) out += (i - 1) * 9 * 9;
    if (k == 3) out += ((i - 1) * (i - 2) * 9 * 9 * 9) / 2;
  }
  if (k == 1) {
    out += a;
  }
  if (k == 2) {
    out += (a - 1) * (s.size() - 1) * 9;
    for (int i = 1; i < s.size(); i++) {
      if (s.at(i) == '0') continue;
      aa = s.at(i);
      if (aa == '1') a = 1;
      if (aa == '2') a = 2;
      if (aa == '3') a = 3;
      if (aa == '4') a = 4;
      if (aa == '5') a = 5;
      if (aa == '6') a = 6;
      if (aa == '7') a = 7;
      if (aa == '8') a = 8;
      if (aa == '9') a = 9;
      out += a;
      out += (s.size() - i - 1) * 9;
    }
  }
  if (k == 3) {
    out += (a - 1) * (s.size() - 1) * (s.size() - 2) * 9 * 9 / 2;
    for (int i = 1; i < s.size(); i++) {
      if (s.at(i) == '0') continue;
      aa = s.at(i);
      if (aa == '1') a = 1;
      if (aa == '2') a = 2;
      if (aa == '3') a = 3;
      if (aa == '4') a = 4;
      if (aa == '5') a = 5;
      if (aa == '6') a = 6;
      if (aa == '7') a = 7;
      if (aa == '8') a = 8;
      if (aa == '9') a = 9;
      out += (a - 1) * (s.size() - i - 1) * 9;
      for (int j = i + 1; j < s.size(); j++) {
        if (s.at(j) == '0') continue;
      }
    }
  }
  cout << out;
}
