跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F1245. Restore a Number

    ID: 1251 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>枚举构造字符串算法思想挑战难度共享题库Codeforces英文题面题目来源题面语言

Restore a Number

题目描述

F. Restore a Number
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Vasya decided to pass a very large integer n to Kate. First, he wrote that number as a string, then he appended to the right integer k− the number of digits in n.

Magically, all the numbers were shuffled in arbitrary order while this note was passed to Kate. The only thing that Vasya remembers, is a non-empty substring of n (a substring of n is a sequence of consecutive digits of the number n).

Vasya knows that there may be more than one way to restore the number n. Your task is to find the smallest possible initial integer n. Note that decimal representation of number n contained no leading zeroes, except the case the integer n was equal to zero itself (in this case a single digit 0 was used).

Input

The first line of the input contains the string received by Kate. The number of digits in this string does not exceed 1000000.

The second line contains the substring of n which Vasya remembers. This string can contain leading zeroes.

It is guaranteed that the input data is correct, and the answer always exists.

Output

Print the smalles integer n which Vasya could pass to Kate.

Examples
Input
003512
021
Output
30021
Input
199966633300
63
Output
3036366999


题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 726 题。保留原作者与原赛事署名。