#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e18, MOD = 1e9 + 7;
const int INT_INF = 1e9, INT_MOD = 1e9 + 7;
signed main() {
  string s;
  cin >> s;
  char a[105];
  for (int i = 0; i < 105; i++) a[i] = 'x';
  for (int i = 0; i < s.size(); i++) {
    a[i] = s[s.size() - 1 - i];
  }
  int k;
  cin >> k;
  long long ans = 0;
  if (k == 1) {
    int i;
    for (i = 0; a[i] != 'x' and a[i + 1] != 'x'; i++) {
      ans += 9;
    }
    ans += (int)(a[i] - '0');
    cout << ans << endl;
  } else if (k == 2) {
    int i = 1;
    if (a[1] == 'x')
      cout << ans << endl;
    else if (a[2] == 'x')
      cout << ((int)a[1] - '0') * 10 + ((int)a[0] - '0') - ((int)a[1] - '0') - 9
           << endl;
    else {
      long long sum = a[0] - '0';
      for (i = 1; a[i] != 'x' and a[i + 1] != 'x'; i++) {
        ans += 81 * i;
        sum += ((int)a[i] - '0');
      }
      ans += ((a[i] - '0') - 1) * 9 * i + sum;
      cout << ans << endl;
    }
  } else {
    int i;
    if (a[2] == 'x')
      cout << ans << endl;
    else if (a[3] == 'x') {
      cout << (a[2] - '0') * 100 + (a[1] - '0') * 10 + (a[0] - '0') -
                  (((a[2] - '0') - 1) * 81 + a[1] + a[0]) - ((a[2] - '0') + 9);
    } else {
      int tmp = 0;
      for (i = 2; a[i] != 'x' and a[i + 1] != 'x'; i++) {
        ans += 729 * i * (i - 1) / 2;
      }
      for (int j = 0; j < i - 1; j++) {
        for (int k = j + 1; k < i; k++) {
          tmp += (a[j] - '0') * (a[k] - '0');
        }
      }
      ans += ((a[i] - '0') - 1) * 9 * 9 * i * (i - 1) / 2 + tmp;
      cout << ans << endl;
    }
  }
  return 0;
}
