#include <bits/stdc++.h>
using namespace std;
void solve() {
  string s;
  long long k;
  cin >> s >> k;
  pair<long long, long long> dp[s.size()][k + 1][10];
  for (long long i = 0; i < s.size(); ++i)
    for (long long j = 0; j <= k; ++j)
      for (long long id = 0; id < 10; ++id) dp[i][j][id] = {0, 0};
  dp[0][0][0] = {1, 0};
  for (long long i = 1; i <= (s[0] - '0'); ++i) dp[0][1][i] = {1, 0};
  dp[0][1][s[0] - '0'].second = 1;
  for (long long i = 1; i < s.size(); ++i) {
    for (long long j = 0; j <= k; ++j) {
      for (long long id = 0; id < 10; ++id) {
        for (long long id2 = 0; id2 < 10; ++id2) {
          if (id2 != 0 && j < k) {
            if (dp[i - 1][j][id].second == 0 || (s[i] - '0') >= id2) {
              dp[i][j + 1][id2].first += dp[i - 1][j][id].first;
              if (dp[i - 1][j][id].second == 1 && (s[i] - '0') == id2)
                dp[i][j + 1][id2].second = 1;
            }
            continue;
          }
          if (id2 != 0) continue;
          dp[i][j][id2].first += dp[i - 1][j][id].first;
          if (dp[i - 1][j][id].second == 1 && (s[i] - '0') == id2)
            dp[i][j][id2].second = 1;
        }
      }
    }
  }
  long long ans = 0;
  for (long long i = 0; i < 10; ++i) ans += dp[s.size() - 1][k][i].first;
  cout << ans;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  solve();
  return 0;
}
