#include <bits/stdc++.h>
using namespace std;
const int max_n = 1e5 + 5;
const double eps = 1e-8;
const double PI = acos(-1.0);
const long long N = 10;
long long p, d;
long long nine[20];
string num_str(long long x) {
  string str = "";
  while (x) {
    str += (x % N) + '0';
    x /= N;
  }
  reverse(str.begin(), str.end());
  return str;
}
long long ans, fans;
int32_t main() {
  for (long long i = 1; i <= 18; i++) nine[i] = nine[i - 1] * 10 + 9;
  while (cin >> p >> d) {
    fans = p;
    string T = num_str(p);
    long long len = T.length();
    long long Min = p - d, Max = p;
    for (long long i = 1; i <= len; i++) {
      long long ans = -1;
      long long tmp = 0;
      for (long long j = len - i; j < len; j++) {
        tmp = tmp * N + T[j] - '0';
      }
      if (tmp != nine[i]) {
        long long y = p - (tmp + 1);
        if (y >= Min && y <= Max) {
          ans = max(ans, y);
        }
      } else {
        ans = max(ans, p);
      }
      if (ans != -1) fans = ans;
    }
    cout << fans << endl;
  }
  return 0;
}
