#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  if (k == 1) {
    int ret = 0;
    for (int i = 0; i < n; i++) {
      int tight = 0, notight = 0;
      if (i == 0)
        tight = 1, notight = s[i] - '1';
      else
        notight = 9;
      ret += tight + notight;
    }
    cout << ret << endl;
  } else if (k == 2) {
    int ret = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        int tight = 0, notight = 0;
        if (i == 0)
          tight = 1, notight = s[i] - '1';
        else
          notight = 9;
        bool nonzero = false;
        for (int index = i + 1; index < j; index++) {
          if (s[index] != '0') nonzero = true;
        }
        if (!nonzero)
          notight *= 9, notight += tight * (s[j] - '1');
        else
          notight = (tight + notight) * 9, tight = 0;
        ret += tight + notight;
      }
    }
    cout << ret << endl;
  } else {
    int ret = 0;
    for (int i = 0; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        for (int k = j + 1; k < n; k++) {
          int tight = 0, notight = 0;
          if (i == 0)
            tight = 1, notight = s[i] - '1';
          else
            notight = 9;
          bool nonzero = false;
          for (int index = i + 1; index < j; index++) {
            if (s[index] != '0') nonzero = true;
          }
          if (!nonzero)
            notight *= 9, notight += tight * max(0, (s[j] - '1'));
          else
            notight = (tight + notight) * 9, tight = 0;
          for (int index = j + 1; index < k; index++) {
            if (s[index] != '0') nonzero = true;
          }
          if (!nonzero)
            notight *= 9, notight += tight * max(0, (s[k] - '1'));
          else
            notight = (tight + notight) * 9, tight = 0;
          ret += tight + notight;
        }
      }
    }
    cout << ret << endl;
  }
  return 0;
}
