#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n, k;
ll ans = 0;
void f(ll i, ll z) {
  if (i > n) return;
  if (z > k) return;
  if (z == k) {
    ans++;
  }
  f(i * 10, z);
  for (int j = 1; j <= 9; ++j) {
    f(i * 10 + j, z + 1);
  }
}
int main() {
  cin >> n >> k;
  for (int i = 1; i <= 9; ++i) {
    f(i, 1);
  }
  cout << ans << endl;
  return 0;
}
