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).
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.
none
003512
021
30021
199966633300
63
3036366999
01
0
0
0000454312911
9213544
92135440000
13
3
3
00010454312921
9213544
100009213544
11317110
01
1011113
1516532320120301262110112013012410838210025280432402042406224604110031740090203024020012
0126064
10000000000000000000000012606411111111111111222222222222222222333333334444444455567889
233121122272652143504001162131110307236110231414093112213120271312010423132181004
0344011
1000000000003440111111111111111111111112222222222222222233333333333444455666778
1626112553124100114021300410533124010061200562040601301
00612141
10000000000000006121411111111111222222333344445556666
040005088
0
40000058
420002200110100211206222101201021321440210
00
1000000000000011111111112222222222223446
801095116
0
10011569
070421120216020020
000024
1000000024122227
825083
0
20388
6201067
0
100267
34404430311310306128103301112523111011050561125004200941114005444000000040133002103062151514033103
010215110013511400400140133404
100000000000000000000102151100135114004001401334041111111111111122222233333333333444444455555668
14
4
4
21
2
2
204
4
40
12
2
2
05740110115001520111222011422101032503200010203300510014413
000151
100000000000000000001511111111111111222222222333334444555
116051111111001510011110101111111101001111111101111101101
00111111111
1000000000000011111111111111111111111111111111111111116
1161100
01110
101110
101313020013110703821620035452130200177115540090000
002001320
1000000000000002001320111111111222333334555567778
03111100110111111118
01001111111101111
301001111111101111
01170141
01114
1001114
0500014440100110264222000342611000102247070652310723
0003217
10000000000000000032171111112222222233444444566677
111011111101111131113111111111011
0111111111111111010111111111
1011111111111111101011111111113
11003040044200003323519101102070252000010622902208104150200400140042011224011154237302003323632011235
0
100000000000000000000000000000000001111111111111111222222222222222222333333333334444444445555566778
111111011110101141110110011010011114110111
01010111111011111
1000000101011111101111111111111111111114
011010171110
010110117
1010110117
510017
0
10017
00111111110114112110011105
0
100000011111111111111115
320403902031031110003113410860101243100423120201101124080311242010930103200001451200132304400000
01
1000000000000000000000000000000000011111111111111111111122222222222233333333333334444444456889
125
15
15
1160190
110019
110019
11111111111101101111110101011111010101001111001110010011810010110111101101112140110110
110101100101111101011111111101111111111110111110011111011000111010100111011111000002
110101100101111101011111111101111111111110111110011111011000111010100111011111000002
2206026141112316065224201412118064151200614042100160093001020024005013121010030020083221011
280060226
10000000000000000000000000111111111111111111111222222222222228006022633333444444455566666
63007511113226210230771304213600010311075400082011350143450007091200
25
100000000000000000000011111111111112222222533333333444455567777789
142245201505011321217122212
12521721230
1001111125217212302222445
712
17
17
11011111111003010101111111111103111
101111111110110111111011001011111
101111111110110111111011001011111
143213104201201003340424615500135122127119000020020017400111102423312241032010400
235321200411204201121201304100003
1000000000000001111111111222222223532120041120420112120130410000333334444445567
080001181
18
10000118
4141403055010511470013300502174230460332129228041229160601006121052601201100001153120100000
49
10000000000000000000000000000011111111111111111112222222222223333333444444495555556666677
2131
112
112
0111110011011110111012109101101111101111150011110111110111001
10110010111111011111111011001101001111111111111110001011012
10110010111111011111111011001101001111111111111110001011012
251137317010111402300506643001203241303324162124225270011006213015100
3512
1000000000000000001111111111111122222222223333333335124444455566677
12140051050330004342310455231200020252193200
23012
100000000000001111222222301233333444555559
291
19
19
11011011000111101111111111081101110001011111101111110111111111011111011011111100111
1110111111111
100000000000000000011101111111111111111111111111111111111111111111111111111111111
170422032160671323013220212523333410720410110020005012206133500200001015971250190240204004002041
10010405153200037262043200214001340010615320
1000000000000000100104051532000372620432002140013400106153201111111122222222222233333445567779
210042022032002310001424611003103312001401111120015141083050404330261401411234412400319100212120
10014121114054
1000000000000000000000000010014121114054111111111111111111222222222222223333333333444444445668
222122228
2221
22212222
10
0
0
11007000
1000
1000001
3323
32
323
1001016
1001
100101
50104
10
1005
2023
20
202
0001116
1001
100101
32334
32
3233
1103
10
101
023335
23
23033
111111111110
1
1111111111
501105
110
11005
1110006
1001
100101
import sys, os, io
input = io.BytesIO(os.read(0, os.fstat(0).st_size)).readline

a = list(input().rstrip())
b = list(input().rstrip())
a, b = [i - 48 for i in a], [i - 48 for i in b]
cnt = [0] * 10
for i in a:
    cnt[i] += 1
n = len(a)
for i in range(1, 8):
    if len(str(n - i)) == i:
        u = n - i
        break
for i in str(u):
    cnt[int(i)] -= 1
for i in b:
    cnt[i] -= 1
if not max(cnt[1:]):
    ans = "".join(map(str, b)) + "0" * cnt[0]
elif not b[0]:
    ans = []
    for i in range(1, 10):
        if cnt[i]:
            ans.append(i)
            cnt[i] -= 1
            break
    for _ in range(cnt[0]):
        ans.append(0)
    for i in b:
        ans.append(i)
    for i in range(1, 10):
        for _ in range(cnt[i]):
            ans.append(i)
    ans = "".join(map(str, ans))
else:
    x = list(b)
    for i in range(10):
        for _ in range(cnt[i]):
            x.append(i)
    y, z = [], []
    for i in range(1, 10):
        if b[0] ^ i:
            if cnt[0] and cnt[i]:
                y.append(i)
                z.append(i)
                cnt[i] -= 1
                for _ in range(cnt[0]):
                    y.append(0)
                    z.append(0)
                cnt[0] = 0
            for _ in range(cnt[i]):
                y.append(i)
                z.append(i)
        elif not cnt[i]:
            for j in b:
                y.append(j)
                z.append(j)
        else:
            c = [i]
            cnt[i] -= 1
            for _ in range(cnt[0]):
                c.append(0)
            cnt[0] = 0
            for _ in range(cnt[i]):
                c.append(i)
            for j in b + c:
                y.append(j)
            for j in c + b:
                z.append(j)
    ans = min("".join(map(str, x)), "".join(map(str, y)), "".join(map(str, z)))
print(ans)