670_F. Restore a Number
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.

Examples

Input

003512
021


Output

30021


Input

199966633300
63


Output

3036366999
```python
a = input()
b = input()
d = [0] * 10
n = 0
for j in range(1000100):
    t = str(j)
    if len(t) + j == len(a):
        n = j
for x in str(n):
    d[ord(x) - ord('0')] -= 1
for x in a:
    d[ord(x) - ord('0')] += 1
for x in b:
    d[ord(x) - ord('0')] -= 1
if sum(d)==0:
    print(b)
else:
    A = []
    B = []
    C = []
    D = []
    if b[0] != '0':
        A = list(b)
        for j in range(10):
            for k in range(d[j]):
                A.append(chr(ord('0') + j))
    t = 1
    while t < len(d) and d[t] == 0:
        t += 1
    oo = ord('0')
    if t < len(d):
        B.append(chr(oo+t))
        d[t] -= 1
        for j in range(ord(b[0]) - oo):
            for k in range(d[j]):
                B.append(chr(ord('0') + j))
        B.extend(list(b))
        for j in range(ord(b[0]) - oo, 10):
            for k in range(d[j]):
                B.append(chr(ord('0') + j))
        
        
        C.append(chr(oo+t))
        for j in range(min(ord(b[0]) - oo+1, 10)):
            for k in range(d[j]):
                C.append(chr(ord('0') + j))
        C.extend(list(b))
        for j in range(ord(b[0]) - oo+1, 10):
            for k in range(d[j]):
                C.append(chr(ord('0') + j))
        
    ans = []
    if len(A) > 0:
        ans.append(''.join(A))
    
    if len(B) > 0:
        ans.append(''.join(B))
    
    if len(C) > 0:
        ans.append(''.join(C))
    
    print(min(ans))
```