#include <bits/stdc++.h>
using namespace std;
bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.second < b.second)
    return true;
  else if (a.second == b.second)
    return a.first < b.first;
  else
    return false;
}
bool sortbyboth(const pair<int, int> &a, const pair<int, int> &b) {
  if (a.first < b.first)
    return true;
  else if (a.first == b.first)
    return a.second < b.second;
  else
    return false;
}
unsigned long long powr(unsigned long long x1, unsigned long long n1) {
  if (x1 == 0) {
    return 0;
  }
  unsigned long long result = 1;
  while (n1 > 0) {
    if (n1 & 1) {
      result = (result * x1);
    }
    n1 = n1 >> 1;
    x1 = (x1 * x1);
  }
  return result;
}
int days(int month, int year) {
  if (month == 2) {
    if ((year % 400 == 0) || (year % 4 == 0 && year % 100 != 0))
      return 29;
    else
      return 28;
  } else if (month == 1 || month == 3 || month == 5 || month == 7 ||
             month == 8 || month == 10 || month == 12)
    return 31;
  else
    return 30;
}
int dayofweek(int d, int m, int y) {
  static int t[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
  y -= m < 3;
  return (y + y / 4 - y / 100 + y / 400 + t[m - 1] + d) % 7;
}
int main() {
  ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  srand(time(NULL));
  string s;
  cin >> s;
  int k;
  cin >> k;
  long long ans = 0;
  for (int i = k; i < s.size(); i++) {
    if (k == 1) {
      ans += 9;
    } else if (k == 2) {
      long long r = 9 * (i - 1);
      ans += r * 9;
    } else if (k == 3) {
      long long r = (36 * (i - 1) * (i - 2));
      r += (9 * (i - 1) * (i - 2)) / 2;
      ans += r * 9;
    }
  }
  if (k > s.size()) {
    cout << 0;
    return 0;
  }
  if (k == 1) {
    ans += (s[0] - '0');
  } else {
    long long r1 = 0;
    long long r;
    for (int i = 0; i < k; i++) {
      r1 *= 10;
      r1 += ((s[i] - '0'));
    }
    int i;
    if (k == 2)
      i = 10;
    else
      i = 100;
    for (; i <= r1; i++) {
      string s1 = to_string(i);
      int cnt = 0;
      for (int j = 0; j < s1.size(); j++) {
        if (s1[j] == '0') {
          cnt++;
        }
      }
      r = (s.size() - k);
      cnt += (k - s1.size());
      if (r > 0 && cnt > 0) {
        if (cnt == 1) {
          ans += (9 * r);
        } else if (cnt == 2 && r >= 2) {
          ans += (36 * (r * (r - 1)));
          ans += (9 * r * (r - 1)) / 2;
        }
      } else if (cnt == 0) {
        ans++;
      }
    }
  }
  cout << ans;
  return 0;
}
