#include <bits/stdc++.h>
using namespace std;
int N = 1e6;
vector<bool> prime(N + 1, true);
vector<int> che;
void pri(int n) {
  for (int i = 2; i <= min(n, N); i++) {
    if (prime[i]) {
      che.push_back(i);
      for (int j = i * i; j <= n; j += i) {
        prime[j] = false;
      }
    }
  }
  return;
}
string rec(string k, string st) {
  string a = st + k;
  string b = k + st;
  string r = min(a, b);
  return r;
}
int count(long long int na) {
  int cnt = 0;
  while (na) {
    int rem = na % 10;
    na /= 10;
    if (rem == 9)
      cnt++;
    else
      break;
  }
  return cnt;
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  long long int n, d;
  cin >> n >> d;
  long long int na = n;
  int cnt = 0;
  while (na) {
    int rem = na % 10;
    na /= 10;
    if (rem == 9)
      cnt++;
    else
      break;
  }
  na = n;
  long long int val = n;
  int cntt = cnt;
  while (n - na <= d) {
    if (count(na) > cntt) {
      cntt = count(na);
      val = na;
    }
    long long int sum = pow(10, ++cnt);
    long long int su = na / sum;
    na = sum * su - 1;
  }
  cout << val << "\n";
}
