#include <bits/stdc++.h>
using namespace std;
long int ans = 0;
void fff(string s, vector<bool> f, int k, int m = 0, int l = 1) {
  if (l > k) {
    int a = 1;
    bool x = false;
    for (int i = 0; i < s.size(); ++i) {
      if (f[i] == false && x == false) {
        x = true;
      }
      if (f[i] && x) {
        cerr << i << "a";
        a *= 9;
      } else if (f[i]) {
        cerr << i << "b";
        a *= (s[i] - '0');
      }
    }
    ans += a;
    cerr << endl;
    x = false;
  } else {
    for (int i = m; i < s.size(); ++i) {
      if (f[i]) continue;
      f[i] = true;
      fff(s, f, k, i + 1, l + 1);
      f[i] = false;
    }
  }
}
int main() {
  string s;
  int k;
  cin >> s >> k;
  vector<bool> f(s.size(), false);
  fff(s, f, k);
  cout << ans << endl;
}
