#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1e9 + 7;
long long dp[110][2][4];
int main() {
  string S;
  cin >> S;
  int N = S.size();
  int K;
  cin >> K;
  dp[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int k = 0; k < 2; k++) {
      for (int l = 0; l <= K; l++) {
        for (int m = 0; m < 2; m++) {
          if (m == 0) {
            int nk = 1, nl = l;
            if (nl > K) continue;
            dp[i + 1][nk][nl] += dp[i][k][l];
          } else {
            for (int p = 1; p <= 9; p++) {
              int nk = k, nl = l + 1;
              if (nl > K) continue;
              if (k == 0 && S[i] - '0' > p) nk = 1;
              if (k == 0 && S[i] - '0' < p) continue;
              dp[i + 1][nk][nl] += dp[i][k][l];
            }
          }
        }
      }
    }
  }
  long long ans = 0;
  for (int k = 0; k < (2); ++k) ans += dp[N][k][K];
  cout << ans << endl;
  return 0;
}
