#include <bits/stdc++.h>
using namespace std;
int dp[1000000];
int check_digit(int num) {
  int digit = 0;
  if (num == 0) return 0;
  while (num != 0) {
    digit++;
    num /= 10;
  }
  return digit;
}
int check_k(int num, int k) {
  int i = 0;
  while (num != 0) {
    if (num % 10 != 0) {
      i++;
    }
    num /= 10;
  }
  if (i == k)
    return 1;
  else
    return 0;
}
int combi(int n, int r) {
  if (n == 0)
    return 1;
  else if (r == 0)
    return 1;
  else if (n == r)
    return 1;
  else
    return combi(n - 1, r) + combi(n - 1, r - 1);
}
int main() {
  int n, k;
  int ans = 0;
  cin >> n >> k;
  int digit = check_digit(n);
  if (digit < k) {
    cout << "0";
    return 0;
  } else if (digit == k) {
  } else {
    ans += combi(digit - 1, k) * pow(9, k);
  }
  int low = (int)pow(10, digit - 1);
  for (int i = low; i <= n; i++) {
    ans += check_k(i, k);
  }
  cout << ans;
  return 0;
}
