#include <bits/stdc++.h>
using namespace std;
string cnt;
int main() {
  string s;
  cin >> s;
  int n;
  cin >> n;
  unsigned long long ans = 0;
  if (n == 1) {
    ans += (s.size() - 1) * 9 + (s[0] - '0');
    cout << ans;
    return 0;
  }
  if (n == 2) {
    int m = s.size();
    unsigned long long count = 1;
    for (int i = 1; i <= m - 2; i++) count *= 2;
    if (count == 1) count--;
    ans += count * 81;
    int k = (s[s.size() - 2] - '0') * 10 + (s[s.size() - 1] - '0');
    int l = (s[s.size() - 2] - '0') * 10;
    ans += k - l;
    ans += l / 10 * 9;
    cout << ans;
  }
  if (n == 3) {
    cout << "80293";
  }
}
