#include <bits/stdc++.h>
using namespace std;
long long p, d, resp;
int qtd;
long long twilightsparkleisbestpony[20];
long long get(int x) {
  return ((p / twilightsparkleisbestpony[x]) * twilightsparkleisbestpony[x]) -
         1LL;
}
bool test(int x) { return ((p + 1LL) % twilightsparkleisbestpony[x]) == 0LL; }
int main() {
  cin.sync_with_stdio(false);
  twilightsparkleisbestpony[0] = 1LL;
  for (int i = 1; i < 19; ++i)
    twilightsparkleisbestpony[i] = (twilightsparkleisbestpony[i - 1] << 3) +
                                   (twilightsparkleisbestpony[i - 1] << 1);
  cin >> p >> d;
  qtd = 0;
  for (int i = 0; i < 18; ++i) {
    if (test(i) || ((p - get(i)) <= d)) qtd = i;
  }
  if (test(qtd))
    cout << p << endl;
  else
    cout << get(qtd) << endl;
  return 0;
}
