#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1000000007;
const long long int INF = (long long int)1e15;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  long long int K;
  cin >> S >> K;
  long long int ans = 0;
  long long int N = S.length();
  for (long long int(k) = (0); (k) < (K + 1); ++(k)) {
    {
      long long int t = 1, m = 1;
      for (long long int(i) = (0); (i) < (K - k); ++(i)) {
        t *= (N - 1 - k - i);
        m *= (i + 1);
      }
      ans += (t / m) * pow(9, K - k);
    }
    {
      long long int t = 1, m = 1;
      for (long long int(i) = (0); (i) < (K - k - 1); ++(i)) {
        t *= (N - 1 - k - i);
        m *= (i + 1);
      }
      ans += std::max(0, (S[k] - '1')) * (t / m) * pow(9, K - k - 1);
    }
  }
  cout << ans << endl;
  return 0;
}
