#include <bits/stdc++.h>
using namespace std;
int main() {
  int K, p;
  double N = 0, count = 0;
  cin >> N >> K;
  p = to_string(N).size();
  if (p > 1 && p > K) count = 9 * K * (p - 1);
  count += 9 * (K - 1) * (int)(to_string(N).at(p - 2));
  count += (int)(to_string(N).at(p - 1));
  cout << count << endl;
}
