#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1.0);
const ll MOD = 1e9 + 7;
const ll INF = 100000000000;
string s;
ll k;
ll dp[105][2][5];
int main() {
  cin >> s >> k;
  ll n = ((ll)(s).size());
  dp[0][0][0] = 1;
  for (ll i = 0; i < n; i++) {
    for (ll sm = 0; sm < 2; sm++) {
      for (ll j = 0; j < k + 1; j++) {
        ll c_ = s[i] - '0';
        for (ll c = 0; c < 10; c++) {
          if (sm)
            dp[i + 1][1][(c == 0) ? j : j + 1] += dp[i][1][j];
          else {
            if (c == 0)
              dp[i + 1][1][j] += dp[i][sm][j];
            else if (c < c_)
              dp[i + 1][1][j + 1] += dp[i][sm][j];
            else if (c == c_)
              dp[i + 1][0][j + 1] += dp[i][sm][j];
          }
        }
      }
    }
  }
  cout << dp[n][0][k] + dp[n][1][k] << "\n";
  return 0;
}
