#include <bits/stdc++.h>
using namespace std;
long long dp[100][2][4];
int main() {
  string s;
  cin >> s;
  long long k;
  cin >> k;
  dp[0][0][0] = 1;
  for (long long i = 0; i < s.size(); i++) {
    for (long long j = 0; j <= 9; j++) {
      if (s[i] - '0' == j) {
        if (j == 0) {
          for (long long l = 0; l < 4; l++) {
            dp[i + 1][0][l] += dp[i][0][l];
            dp[i + 1][1][l] += dp[i][1][l];
          }
        } else {
          for (long long l = 0; l < 4; l++) {
            dp[i + 1][0][l + 1] += dp[i][0][l];
            dp[i + 1][1][l + 1] += dp[i][1][l];
          }
        }
      } else {
        if (j == 0) {
          for (long long l = 0; l < 4; l++) {
            dp[i + 1][1][l] += dp[i][0][l];
            dp[i + 1][1][l] += dp[i][1][l];
          }
        } else {
          for (long long l = 0; l < 4; l++) {
            if (s[i] - '0' > j) {
              dp[i + 1][1][l + 1] += dp[i][0][l];
            }
            dp[i + 1][1][l + 1] += dp[i][1][l];
          }
        }
      }
    }
  }
  cout << dp[s.size()][0][k] + dp[s.size()][1][k];
  return 0;
}
