Codeforces Round 350 (Div. 2)
F
Restore a Number
Codeforces
2300
原题
← E→
翻译中…

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 $1 000 000$.

翻译中…

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.

翻译中…

样例

Input #1
003512
021
Output #1
30021
InputCopy OutputCopy
Input #2
199966633300
63
Output #2
3036366999
InputCopy OutputCopy
题目信息
题号
670F
时间限制
2 s
内存限制
256 MB
标签
暴力
构造
字符串

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。