#include <bits/stdc++.h>
using namespace std;
const long long int inf = 1000000000;
const long long int MOD = 1000000007;
int main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  register long long int i, j, k, x, y, m, n, t, q, temp, sum = 0, count = 0,
                                                          f = 1;
  string p, d;
  cin >> p >> d;
  n = p.length();
  x = stoll(p);
  y = stoll(d);
  t = x - y;
  long long int ans = x;
  for (i = n - 1; i > 0; i--) {
    if (p[i] == '9') {
      j = stoll(p);
      if (!(j >= t)) {
        break;
      } else {
        ans = j;
      }
    } else {
      p[i] = '9';
      if (p[i - 1] == '0') {
        temp = i - 1;
        while (temp >= 0) {
          if (p[temp] == '0') {
            p[temp] = '9';
            temp--;
          } else {
            p[temp] = p[temp] - 1;
            break;
          }
        }
      } else {
        p[i - 1] = p[i - 1] - 1;
      }
      j = stoll(p);
      if (!(j >= t)) {
        break;
      } else {
        ans = j;
      }
    }
  }
  cout << ans;
}
