#include <bits/stdc++.h>
using namespace std;
inline void read(int &x) {
  short negative = 1;
  x = 0;
  char c = getchar();
  while (c < '0' || c > '9') {
    if (c == '-') negative = -1;
    c = getchar();
  }
  while (c >= '0' && c <= '9')
    x = (x << 3) + (x << 1) + (c ^ 48), c = getchar();
  x *= negative;
}
inline void write(long long x) {
  static long long sta[35];
  long long top = 0;
  do {
    sta[top++] = x % 10, x /= 10;
  } while (x);
  while (top) putchar(sta[--top] + 48);
  puts("");
}
bool prime(int n) {
  if (n == 0 || n == 1) return false;
  for (int i = 2; i * i <= n; i++)
    if (n % i == 0) return false;
  return true;
}
const long long power(int n, int k) {
  long long t = 1;
  for (int i = 0; i < (int)(k); i++) t *= n;
  return t;
}
const string turn2(int n) {
  string s = "";
  while (n != 0) {
    s += (char)(n % 2 + '0');
    n /= 2;
  }
  reverse(s.begin(), s.end());
  return s;
}
const string turn16(int n) {
  string s = "";
  while (n != 0) {
    if (n % 16 > 9)
      s += (char)('A' + n % 16 - 10);
    else
      s += (char)('0' + n % 16);
    n /= 16;
  }
  reverse(s.begin(), s.end());
  return s;
}
const long long quickpower(int n, int k) {
  if (k == 1) return n;
  if (k % 2 == 1)
    return n * quickpower(n, k / 2) * quickpower(n, k / 2);
  else
    return quickpower(n, k / 2) * (quickpower(n, k / 2));
}
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
int ans = 0, k;
string s;
string int_to_string(int p) {
  string g = "";
  while (p) {
    g += (char)(p % 10 + '0');
    p /= 10;
  }
  reverse(g.begin(), g.end());
  return g;
}
bool checkstring(string a, string b) {
  if ((int)a.size() > (int)b.size()) return 0;
  if ((int)a.size() < (int)b.size()) return 1;
  for (int i = 0; i < (int)(a.size()); i++) {
    if (a[i] > b[i]) return 0;
    if (a[i] < b[i]) return 1;
  }
  return 1;
}
void dfs(string n, int n0) {
  cout << n << endl;
  if (!checkstring(n, s) || n0 > k)
    return;
  else {
    if (n0 == k) {
      if (k == 1) {
        string g = n;
        for (int i = 0; i < (int)(s.size()); i++) {
          g += '0';
          if (checkstring(g, s))
            ans++;
          else
            break;
        }
      }
      if (k == 2) {
        string g1 = "";
        g1 += n[0];
        string g2 = "";
        g2 += n[1];
        for (int i = 0; i < (int)(s.size()); i++) {
          g1 += '0';
          for (int j = 0; j < (int)(s.size()); j++) {
            g2 += '0';
            string t = g1 + g2;
            if (checkstring(t, s))
              ans++;
            else
              break;
          }
        }
      }
      if (k == 3) {
        string g1 = "";
        g1 += n[0];
        string g2 = "";
        g2 += n[1];
        string g3 = "";
        g3 += n[2];
        for (int i = 0; i < (int)(s.size()); i++) {
          g1 += '0';
          for (int j = 0; j < (int)(s.size()); j++) {
            g2 += '0';
            for (int k = 0; k < (int)(s.size()); k++) {
              g3 += '0';
              string t = g1 + g2 + g3;
              if (checkstring(t, s))
                ans++;
              else
                break;
            }
          }
        }
      }
    } else {
      for (int i = 0; i < 10; i++) {
        string p = n;
        p += (i + '0');
        if (i == 0)
          dfs(p, n0);
        else
          dfs(p, n0 + 1);
      }
    }
  }
}
int main() {
  cin >> s;
  cin >> k;
  for (int i = 1; i < 10; i++) {
    string j = "";
    j += (i + '0');
    dfs(j, 1);
  }
  cout << ans << endl;
  return 0;
}
