#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll dp[1005][2][1005];
int main(void) {
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  dp[0][0][0] = 1;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i + 1][1][j] += dp[i][1][j] * 9;
      dp[i + 1][1][j + 1] += dp[i][1][j];
      int a = s[i] - '0';
      if (a > 0) {
        dp[i + 1][1][j] += dp[i][0][j] * a;
        dp[i + 1][1][j + 1] += dp[i][0][j];
      } else if (a == 0) {
        dp[i + 1][1][j + 1] += dp[i][0][j];
      }
      if (a == 0) {
        dp[i + 1][0][j + 1] = dp[i][0][j];
      } else {
        dp[i + 1][0][j] = dp[i][0][j];
      }
    }
  }
  ll ans = 0;
  for (int j = 0; j < n + 1; j++) ans += (dp[n][0][j] + dp[n][1][j]) * j;
  cout << ans << endl;
}
