#include <bits/stdc++.h>
using namespace std;
string s;
int K, dp1[101], dp2[101], dp3[101];
int main() {
  ios::sync_with_stdio(false);
  cin >> s >> K;
  int ans = 0;
  int l = s.length();
  cout << l << endl;
  for (long long i = 0; i < l; ++i) dp1[i] = 9 * i;
  for (long long i = 1; i < l; ++i) dp2[i] = 9 * dp1[i - 1] + dp2[i - 1];
  for (long long i = 2; i < l; ++i) dp3[i] = 9 * dp2[i - 1] + dp3[i - 1];
  if (K == 3) {
    if (l <= 2) {
      cout << 0 << endl;
      return 0;
    }
    ans += dp3[l - 1];
    int s1, s2, s3;
    s1 = s[0] - '0';
    s2 = s[1] - '0';
    s3 = s[2] - '0';
    ans += s3 + 9 * (s2 - 1) + 9 * 9 * (s1 - 1);
    ans += s2 * 9 * (l - 3);
    ans += s1 * dp2[l - 1];
  } else if (K == 2) {
    if (l <= 1) {
      cout << 0 << endl;
      return 0;
    }
    ans += dp2[l - 1];
    int s1, s2;
    s1 = s[0] - '0';
    s2 = s[1] - '0';
    ans += s2 + 9 * (s1 - 1) + s1 * 9 * (l - 2);
  } else if (K == 1) {
    ans += dp1[l - 1];
    int s1;
    s1 = s[0] - '0';
    ans += s1;
  }
  cout << ans << endl;
  return 0;
}
