#include <bits/stdc++.h>
using namespace std;
int aa[1005];
int bb[1005];
long long wei(long long x) {
  long long a = 0;
  while (x) {
    aa[a] = x % 10;
    x /= 10;
    a++;
  }
  return a;
}
long long wei2(long long x) {
  long long a = 0;
  while (x) {
    bb[a] = x % 10;
    x /= 10;
    a++;
  }
  return a;
}
long long ksm(long long a, long long b) {
  long long res = 1;
  while (b) {
    if (b % 2 == 1) res = res * a;
    a = a * a;
    b /= 2;
  }
  return res;
}
int main(int argc, char** argv) {
  long long p, d;
  cin >> p >> d;
  int wp = wei(p);
  int wd = wei2(d);
  long long ans = 0;
  long long u = wp, n = 0, pp = 0;
  while (u) {
    if (aa[u - 1] == 9) n++;
    u--;
  }
  ans = max(ans, n);
  n = 0;
  u = wp;
  while (u) {
    if (aa[u - 1] == 9) n++;
    ans = max(ans, n);
    if (u > wp || p % ksm(10, u) >= d) {
      u--;
      continue;
    }
    int q = aa[u - 1] == 9 ? 1 : 0;
    if (aa[u - 1] == 1) q--;
    if (ans < n - q + u) {
      pp = p % ksm(10, u) + 1;
      ans = max(n - q + u, ans);
    }
    u--;
  }
  cout << p - pp;
  return 0;
}
