#include <bits/stdc++.h>
using namespace std;
long long int toint(string str) {
  long long int x = 1, sum = 0;
  for (long long int i = str.size() - 1; i >= 0; i--) {
    sum = sum + ((int)str[i] - '0') * x;
    x = x * 10;
  }
  return sum;
}
int main() {
  long long int n, k;
  cin >> n >> k;
  long long int max = n, min = n - k;
  string s = to_string(max);
  vector<long long int> v;
  for (long long int i = s.length() - 1; i >= 0; i--) {
    if (s[i] != '9' && i - 1 >= 0) {
      s[i] = '9';
      s[i - 1] = (char)(((int)(s[i - 1])) - 1);
      long long int a = toint(s);
      if (a >= min && a <= max) {
        v.push_back(a);
      }
    } else {
      long long int a = toint(s);
      if (a >= min && a <= max) {
        v.push_back(a);
      }
    }
  }
  if (v.size() != 0) {
    sort(v.begin(), v.end());
    long long int ans = -1, ind;
    for (long long int i = 0; i < v.size(); i++) {
      long long int p = v[i], cnt = 0;
      while (p > 0) {
        if (p % 10 == 9) {
          cnt++;
        }
        p = p / 10;
      }
      if (cnt > ans) {
        ans = cnt;
        ind = i;
      }
    }
    cout << v[ind] << endl;
    return 0;
  }
  cout << n << endl;
  return 0;
}
