#include <bits/stdc++.h>
using namespace std;
int k;
string s;
long long a[111][111];
void init() {
  a[0][0] = 0;
  for (int i = 1; i <= 101; i++) {
    a[i][0] = 1;
    for (int j = 1; j <= 101; j++) {
      a[i][j] = a[i - 1][j] + a[i - 1][j - 1];
    }
  }
}
long long dfs(string s1, int k1) {
  int n = s1.length();
  if (n == 1) return s1[0] - '0';
  long long d = n - 1;
  long long c = pow(9, k1);
  cout << a[n - 1][k1] << '\n';
  int f;
  if (k1 == 1)
    f = n - 1;
  else if (k1 == 2)
    f = (n - 1) * (n - 2) / 2;
  else
    f = (n - 1) * (n - 2) * (n - 3) / 6;
  long long ans = f * c;
  long long t = s[0] - '0' - 1;
  ans = ans + t * d * 9;
  ans = ans + (d - 1) * 9 + s1[1] - '0';
  return ans;
}
int main() {
  cin >> s >> k;
  init();
  if (k > s.length())
    cout << 0 << '\n';
  else
    cout << dfs(s, k);
}
