#include <bits/stdc++.h>
using namespace std;
long long n, p, need = 0, t, n2, power = 1;
string s, ss;
int main(int argc, char **argv) {
  cin >> s >> p;
  int j, i, l = (int)s.size();
  for (i = 0; i < l; ++i) n = n * 10 + s[i] - '0';
  for (i = l - 1; i >= 0; --i) {
    t = 9 - (s[i] - '0');
    if (t) {
      ss = s;
      s[i] = '9';
      for (j = i - 1; j >= 0; --j)
        if (s[j] > '0') {
          --s[j];
          for (int k = i; k > j; --k) s[k] = '9';
          break;
        }
      if (j < 0) {
        s[i] -= t;
        break;
      }
      n2 = 0;
      for (int d = 0; d < l; ++d) n2 = n2 * 10 + s[d] - '0';
      if (abs(n - n2) > p) {
        s = ss;
        break;
      }
    }
  }
  i = 0;
  while (i < l && s[i] == '0') ++i;
  for (; i < l; ++i) putchar(s[i]);
  cout << endl;
}
