#include <bits/stdc++.h>
using namespace std;
const long long INF = 1e7;
const long long N = 1e5 + 7;
const long long mod = 1e9 + 7;
const long double eps = 1E-7;
long double a, n, b, c = 1, d, cnt, m, ans;
string s, s1, s2;
multiset<char> st;
long long used[N];
vector<int> v;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    s = to_string(i);
    for (auto it : s)
      if (it != '0') st.insert(it);
    if (st.size() == m) cnt++;
    st.clear();
  }
  cout << cnt;
}
