#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e7;
const double pi = 3.1415926535897;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
struct edge {
  int from, to, w;
  edge(int uu, int vv, int ww) : from(uu), to(vv), w(ww) {}
  bool operator<(const edge &rhs) const { return w > rhs.w; }
};
const int N = 205;
long long func(long long x) {
  if (x % 10 != 9)
    return 0;
  else
    return 1LL + func(x / 10LL);
}
int main() {
  long long p, d;
  cin >> p >> d;
  long long ans = p, cnt = func(p);
  long long base = 1;
  while (true) {
    base *= 10LL;
    long long temp = (long long)(p / base) * base - 1LL;
    if (temp > p) continue;
    if (p - temp > d || temp < 0) break;
    if (func(temp) > cnt) {
      ans = temp;
      cnt = func(p);
    }
  }
  cout << ans << "\n";
}
