#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
using namespace std;
void file() {}
int tc;
const int N = 2e5 + 5, M = 2e6 + 5, MOD = 1e9 + 7, OO = 1e9;
string a;
int k;
int n;
long long memo[105][5][2];
long long solve(int indx, int curr, bool already) {
  if (indx == n) {
    return (curr == k);
  }
  long long &ret = memo[indx][curr][already];
  if (~ret) return ret;
  ret = 0;
  if (already) {
    ret = solve(indx + 1, curr, 1);
    for (int i = 1; i <= 9; i++) {
      ret += solve(indx + 1, curr + 1, 1);
    }
  } else {
    ret = solve(indx + 1, curr, 1) +
          solve(indx + 1, curr + (int)(a[indx] != '0'), 0);
    for (int i = 1; i < (a[indx] - '0'); i++)
      ret += solve(indx + 1, curr + 1, 1);
  }
  return ret;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> a >> k;
  n = ((int)(a).size());
  memset(memo, -1, sizeof(memo));
  cout << solve(0, 0, 0) << endl;
}
