#include <bits/stdc++.h>
#pragma GCC optimize(2)
#pragma GCC optimize(3)
using namespace std;
const int mod = 1e9 + 7;
template <class T>
inline void read(T& x) {
  T f = 1;
  x = 0;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -1;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = (x << 1) + (x << 3) + (s & 15);
    s = getchar();
  }
  x *= f;
}
inline void print(__int128 x, char s) {
  if (x >= 10) {
    print(x / 10, 'S');
  }
  putchar(x % 10 + '0');
  if (s != 'S') putchar(s);
}
inline void print(__int128 x) {
  if (x >= 10) {
    print(x / 10);
  }
  putchar(x % 10 + '0');
}
template <class T>
inline T fabs(T a) {
  return a > 0 ? a : -a;
}
char s[101];
__int128 n, num[101], x, f[101][4];
inline __int128 dfs(__int128 k, __int128 sx, __int128 cnt) {
  if (k > n) return (cnt == x);
  if (cnt > x) return 0;
  if (!sx && f[k][cnt]) return f[k][cnt];
  __int128 mx, ans = 0;
  if (sx)
    mx = num[k];
  else
    mx = 9;
  for (__int128 i = 0; i <= mx; i++) {
    if (i == 0)
      ans += dfs(k + 1, 0, cnt);
    else
      ans += dfs(k + 1, (sx && (i == mx)), cnt + 1);
  }
  return f[k][cnt] = ans;
}
signed main() {
  scanf("%s", s + 1);
  n = strlen(s + 1);
  for (__int128 i = 1; i <= n; i++) num[i] = s[i] - '0';
  read(x);
  print(dfs(1, 1, 0));
}
