#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
const long long MOD = 1000000007;
long long n, m, k, ans;
string s, t;
int main() {
  string s;
  cin >> s;
  int k;
  cin >> k;
  long long ans = 0;
  int n = s.size();
  long long tmp;
  if (s[0] != '1') {
    for (int j = 1; j < n; j++) {
      if (k == 3) {
        int sum = 0;
        for (int l = j + 1; l < n; l++) {
          sum += s[l];
        }
        ans += (s[j] - '0') * sum;
      }
      if (k == 2) ans += (s[j] - '0');
    }
    if (k == 2) {
      for (int i = 1; i < n; i++) ans += (s[0] - '0') * 9;
    } else {
      for (int i = 1; i < n; i++) {
        for (int j = i + 1; j < n; j++) ans += (s[0] - '0') * 9 * 9;
      }
    }
  } else {
    ans++;
  }
  if (k == 1)
    for (int i = 1; i < n; i++) {
      ans += 9;
    }
  else if (k == 2) {
    for (int i = 1; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        ans += 9 * 9;
      }
    }
  } else if (k == 3) {
    for (int i = 1; i < n; i++) {
      for (int j = i + 1; j < n; j++) {
        for (int l = j + 1; l < n; l++) ans += 9 * 9 * 9;
      }
    }
  }
  cout << ans << "\n";
}
