#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T>
void printVec(vector<T> vec) {
  cout << "[";
  for (auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}
int main() {
  string n;
  int k;
  cin >> n >> k;
  int l = n.length();
  vector<int> keta(100, 0);
  vector<int> nine(100, 9);
  for (int i = 0; i < (l); ++i) {
    keta[i] = n[i] - '0';
  }
  ll ans = 0;
  if (k == 1) {
    ans += 1;
    keta[0] -= 1;
    for (int i = 0; i < (l - 1); ++i) {
      ans += nine[i];
    }
  }
  if (k == 2) {
    ans += keta[1];
    for (int i = (2); i < (l); ++i) {
      ans += nine[i];
    }
    nine[0] = keta[0] - 1;
    for (int i = 0; i < (l); ++i) {
      for (int j = (i + 1); j < (l); ++j) {
        ans += (nine[i] * nine[j]);
      }
    }
  }
  if (k == 3) {
    int S = ((l - 3) * (l - 4)) / 2;
    for (int i = (2); i < (l); ++i) {
      ans += keta[i];
    }
    nine[0] = keta[1] - 1;
    for (int i = 0; i < (l - 1); ++i) {
      for (int j = (i + 1); j < (l - 1); ++j) {
        ans += (nine[i] * nine[j]);
      }
    }
    nine[0] = keta[0] - 1;
    for (int i = 0; i < (l); ++i) {
      for (int j = (i + 1); j < (l); ++j) {
        for (int x = (j + 1); x < (l); ++x) {
          ans += (nine[i] * nine[j] * nine[x]);
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}
