#include <bits/stdc++.h>
using namespace std;
long long int gcd(long long int a, long long int b) {
  return b ? gcd(b, a % b) : a;
}
long long int lcm(long long int a, long long int b) {
  return a / gcd(a, b) * b;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
const long long int MOD = 1e9 + 7;
const long long int INF = 1e18;
const long double PI = (acos(-1));
signed main() {
  string N;
  long long int K;
  cin >> N >> K;
  long long int dp[105][4][2];
  dp[0][0][0] = 1;
  long long int len = N.size();
  for (long long int i = 0; i < (long long int)(len); i++) {
    for (long long int j = 0; j < (long long int)(4); j++) {
      for (long long int k = 0; k < (long long int)(2); k++) {
        long long int nd = N[i] - '0';
        for (long long int d = 0; d < (long long int)(10); d++) {
          long long int ni = i + 1, nj = j, nk = k;
          if (d != 0) nj++;
          if (nj > K) continue;
          if (k == 0) {
            if (d > nd) continue;
            if (d < nd) nk = 1;
          }
          dp[ni][nj][nk] += dp[i][j][k];
        }
      }
    }
  }
  long long int ans = dp[len][K][0] + dp[len][K][1];
  cout << ans << endl;
}
