#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
map<int, int> mp;
long long n;
long long c(long long a, long long b) {
  if (a <= 0 || b < 0) return 0;
  if (!b || a == b) return 1;
  long long res = 1;
  if (a - b < b) b = a - b;
  for (int i = (a - b) + 1; i <= a; i++) res *= i;
  for (int i = 2; i <= b; i++) res /= i;
  return res;
}
int main() {
  string s;
  int k;
  cin >> s >> k;
  long long ans = 0, sz = s.size();
  if (k == 1) {
    for (int i = 1; i < sz; i++) ans += 9;
    cout << ans + s[0] - '0';
    return 0;
  }
  for (int i = 1; i <= sz; i++)
    if (sz - i >= k) ans += (c(sz - i - 1, k - 1) * pow(9, k));
  cout << ans << ' ' << sz << endl;
  if (k == 2) {
    ans += (c(sz - 1, 1) * 9 * (s[0] - 1 - '0'));
    ans += (c(sz - 2, 1) * (s[2] - '0') + (s[1] - '0'));
  } else if (k == 3) {
    ans += (c(sz - 1, 2) * 9 * 9 * (s[0] - '0' - 1));
    ans += (c(sz - 3, 1) * 9 * (s[1] - '0') + c(sz - 3, 1) * 9 * (s[2] - '0'));
    ans += ((s[1] - '0') * (s[2] - '0'));
    ans += (c(sz - 3, 2) * 9 * 9);
  }
  cout << ans;
  return 0;
}
