import java.io.*;
import java.util.*;

public class numbers_as implements Runnable {

    public void solve() throws IOException {
        Scanner in = new Scanner(new File("numbers.in"));
        PrintWriter out = new PrintWriter(new File("numbers.out"));

        while (true) {
            long n = in.nextLong();
            long k = in.nextLong();

            if (n == 0 && k == 0) {
                break;
            }

            long t = 0;
            int l = 0;
            while (t == 0 || t % k != 0) {
                l++;
                int f = 0;
                if (t == 0) {
                    f = 1;
                }

                search:
                for (int i = f; i <= 9; i++) {
                    long q = t * 10 + i;
                    long d = 1;
                    for (int p = 0; l + p <= 18 || q == 1000000000000000000L; p++) {
                        if (q > n) {
                            continue search;
                        }

                        long r = q + d - 1;
                        if (r > n) {
                            r = n;
                        }

                        if (r - q + 1 >= k || r % k < q % k || q % k == 0) {
                            t = t * 10 + i;
                            break search;
                        }

                        q = q * 10;
                        d = d * 10;
                    }
                }
            }

            out.println(t);
        }

        in.close();
        out.close();
    }

    public void run() {
        try {
            solve();
        } catch (IOException e) {
            System.exit(64);
        }
    }

    public static void main(String[] arg) throws IOException {
        new Thread(new numbers_as()).start();
    }
}
