# def solution(array, commands):
# answer = []
# k = len(commands)
# for i in range(k):
# l = commands[i][1] - commands[i][0] + 1
# d = []
# for j in range(l):
# d.append(array[j + commands[i][0] - 1])
# d.sort()
# answer.append(d[commands[i][2] - 1])
# return answer
#
#
# array1 = list(map(int, input().split()))
# commmands1 = []
# for i in range(3):
# v = list(map(int, input().split()))
# commmands1.append(v)
# print(solution(array1, commmands1))
# def g(b, ans):
# l = len(b)
# for i in range(l):
# if b[i][1] < 10:
# b[i][0] = b[i][1]
# elif b[i][1] >= 10 and b[i][1] < 100:
# b[i][0] = b[i][1] % 10
# elif b[i][1] >= 100 and b[i][1] < 1000:
# b[i][0] = (b[i][1] % 100 - b[i][1] % 10) // 10
# else:
# b[i][0] = (b[i][1] % 1000 - b[i][1] % 100) // 100
# b.sort()
# c = []
# for i in range(l - 1, -1, -1):
# if i != 0 and b[i][0] == b[i - 1][0]:
# c.append(b[i])
# else:
# if len(c) != 0:
# c.append(b[i])
# g1(c, ans)
# c = []
# if i == 0:
# return
# else:
# ans.append(b[i][1])
#
#
# def g1(c, ans):
# l = len(c)
# for i in range(l):
# if c[i][1] < 10:
# c[i][0] = c[i][1]
# elif c[i][1] >= 10 and c[i][1] < 100:
# c[i][0] = c[i][1] // 10
# elif c[i][1] >= 100 and c[i][1] < 1000:
# c[i][0] = c[i][1] % 10
# else:
# c[i][0] = (c[i][1] % 100 - c[i][1] % 10) // 10
# c.sort()
# d = []
# for i in range(l - 1, -1, -1):
# if i != 0 and c[i][0] == c[i - 1][0]:
# d.append(c[i])
# else:
# if len(d) != 0:
# d.append(c[i])
# g2(d, ans)
# d = []
# if i == 0:
# return
# else:
# ans.append(c[i][1])
#
#
# def g2(d, ans):
# l = len(d)
# for i in range(l):
# if d[i][1] < 10:
# d[i][0] = d[i][1]
# elif d[i][1] >= 10 and d[i][1] < 100:
# d[i][0] = d[i][1] // 10 # % 10 or // 10
# elif d[i][1] >= 100 and d[i][1] < 1000:
# d[i][0] = d[i][1] // 100 # % 10 or // 100
# else:
# d[i][0] = d[i][1] % 10
# d.sort()
# e = []
# for i in range(l - 1, -1, -1):
# if i != 0 and d[i][0] == d[i - 1][0]:
# e.append(d[i])
# else:
# if len(e) != 0:
# e.append(d[i])
# g3(e, ans)
# e = []
# if i == 0:
# return
# else:
# ans.append(d[i][1])
#
#
# def g3(e, ans):
# l = len(e)
# e.sort()
# for i in range(l):
# ans.append(e[i][1])
#
#
# def solution(numbers):
# answer = 0
# k = len(numbers)
# numbers1 = [0] * k
# for i in range(k):
# numbers1[i] = int(numbers[i])
# numbers1.sort()
# a = []
# for i in range(k):
# if numbers1[i] < 10:
# v = [numbers1[i], numbers1[i]]
# a.append(v)
# elif numbers1[i] < 100:
# v = [numbers1[i] // 10, numbers1[i]]
# a.append(v)
# elif numbers1[i] < 1000:
# v = [numbers1[i] // 100, numbers1[i]]
# a.append(v)
# else:
# v = [numbers1[i] // 1000, numbers1[i]]
# a.append(v)
# a.sort()
# # print(a)
# b = []
# ans = []
# for i in range(k - 1, -1, -1):
# if i != 0 and a[i][0] == a[i - 1][0]:
# b.append(a[i])
# else:
# if len(b) != 0:
# b.append(a[i])
# g(b, ans)
# b = []
# if i == 0:
# break
# else:
# ans.append(a[i][1])
# # print(ans)
# for i in range(len(ans)):
# if ans[i] < 10:
# answer = answer * 10 + ans[i]
# elif ans[i] >= 10 and ans[i] < 100:
# answer = answer * 100 + ans[i]
# elif ans[i] >= 100 and ans[i] < 1000:
# answer = answer * 1000 + ans[i]
# else:
# answer = answer * 10000 + ans[i]
#
# return str(answer)
def g(b, ans):
l = len(b)
for i in range(l):
if b[i][1] < 10:
b[i][0] = b[i][1]
elif b[i][1] >= 10 and b[i][1] < 100:
b[i][0] = b[i][1] % 10
elif b[i][1] >= 100 and b[i][1] < 1000:
b[i][0] = (b[i][1] % 100 - b[i][1] % 10) // 10
else:
b[i][0] = 0
b.sort()
c = []
for i in range(l - 1, -1, -1):
if i != 0 and b[i][0] == b[i - 1][0]:
c.append(b[i])
else:
if len(c) != 0:
c.append(b[i])
g1(c, ans)
c = []
if i == 0:
return
else:
ans.append(b[i][1])
def g1(c, ans):
l = len(c)
for i in range(l):
if c[i][1] < 10:
c[i][0] = c[i][1]
elif c[i][1] >= 10 and c[i][1] < 100:
c[i][0] = c[i][1] % 10
elif c[i][1] >= 100 and c[i][1] < 1000:
c[i][0] = c[i][1] % 10
else:
c[i][0] = 0
c.sort()
d = []
for i in range(l - 1, -1, -1):
if i != 0 and c[i][0] == c[i - 1][0]:
d.append(c[i])
else:
if len(d) != 0:
d.append(c[i])
g2(d, ans)
d = []
if i == 0:
return
else:
ans.append(c[i][1])
def g2(d, ans):
l = len(d)
for i in range(l):
if d[i][1] < 10:
d[i][0] = d[i][1]
elif d[i][1] >= 10 and d[i][1] < 100:
d[i][0] = d[i][1] // 10
elif d[i][1] >= 100 and d[i][1] < 1000:
d[i][0] = d[i][1] // 100
else:
d[i][0] = 0
d.sort()
e = []
for i in range(l - 1, -1, -1):
if i != 0 and d[i][0] == d[i - 1][0]:
e.append(d[i])
else:
if len(e) != 0:
e.append(d[i])
g3(e, ans)
e = []
if i == 0:
return
else:
ans.append(d[i][1])
def g3(e, ans):
l = len(e)
e.sort()
for i in range(l):
ans.append(e[i][1])
def solution(numbers):
answer = 0
k = len(numbers)
numbers1 = [0] * k
for i in range(k):
numbers1[i] = int(numbers[i])
numbers1.sort()
a = []
for i in range(k):
if numbers1[i] < 10:
v = [numbers1[i], numbers1[i]]
a.append(v)
elif numbers1[i] < 100:
v = [numbers1[i] // 10, numbers1[i]]
a.append(v)
elif numbers1[i] < 1000:
v = [numbers1[i] // 100, numbers1[i]]
a.append(v)
else:
v = [numbers1[i] // 1000, numbers1[i]]
a.append(v)
a.sort()
# print(a)
b = []
ans = []
for i in range(k - 1, -1, -1):
if i != 0 and a[i][0] == a[i - 1][0]:
b.append(a[i])
else:
if len(b) != 0:
b.append(a[i])
g(b, ans)
b = []
if i == 0:
break
else:
ans.append(a[i][1])
# print(ans)
for i in range(len(ans)):
if ans[i] < 10:
answer = answer * 10 + ans[i]
elif ans[i] >= 10 and ans[i] < 100:
answer = answer * 100 + ans[i]
elif ans[i] >= 100 and ans[i] < 1000:
answer = answer * 1000 + ans[i]
else:
answer = answer * 10000 + ans[i]
return str(answer)
na = list(input().split())
print(solution(na))
# def solution(array, commands):
# answer = []
# k = len(commands)
# for i in range(k):
# l = commands[i][1] - commands[i][0] + 1
# d = []
# for j in range(l):
# d.append(array[j + commands[i][0] - 1])
# d.sort()
# answer.append(d[commands[i][2] - 1])
# return answer
#
#
# array1 = list(map(int, input().split()))
# commmands1 = []
# for i in range(3):
# v = list(map(int, input().split()))
# commmands1.append(v)
# print(solution(array1, commmands1))
# def g(b, ans):
# l = len(b)
# for i in range(l):
# if b[i][1] < 10:
# b[i][0] = b[i][1]
# elif b[i][1] >= 10 and b[i][1] < 100:
# b[i][0] = b[i][1] % 10
# elif b[i][1] >= 100 and b[i][1] < 1000:
# b[i][0] = (b[i][1] % 100 - b[i][1] % 10) // 10
# else:
# b[i][0] = (b[i][1] % 1000 - b[i][1] % 100) // 100
# b.sort()
# c = []
# for i in range(l - 1, -1, -1):
# if i != 0 and b[i][0] == b[i - 1][0]:
# c.append(b[i])
# else:
# if len(c) != 0:
# c.append(b[i])
# g1(c, ans)
# c = []
# if i == 0:
# return
# else:
# ans.append(b[i][1])
#
#
# def g1(c, ans):
# l = len(c)
# for i in range(l):
# if c[i][1] < 10:
# c[i][0] = c[i][1]
# elif c[i][1] >= 10 and c[i][1] < 100:
# c[i][0] = c[i][1] // 10
# elif c[i][1] >= 100 and c[i][1] < 1000:
# c[i][0] = c[i][1] % 10
# else:
# c[i][0] = (c[i][1] % 100 - c[i][1] % 10) // 10
# c.sort()
# d = []
# for i in range(l - 1, -1, -1):
# if i != 0 and c[i][0] == c[i - 1][0]:
# d.append(c[i])
# else:
# if len(d) != 0:
# d.append(c[i])
# g2(d, ans)
# d = []
# if i == 0:
# return
# else:
# ans.append(c[i][1])
#
#
# def g2(d, ans):
# l = len(d)
# for i in range(l):
# if d[i][1] < 10:
# d[i][0] = d[i][1]
# elif d[i][1] >= 10 and d[i][1] < 100:
# d[i][0] = d[i][1] // 10 # % 10 or // 10
# elif d[i][1] >= 100 and d[i][1] < 1000:
# d[i][0] = d[i][1] // 100 # % 10 or // 100
# else:
# d[i][0] = d[i][1] % 10
# d.sort()
# e = []
# for i in range(l - 1, -1, -1):
# if i != 0 and d[i][0] == d[i - 1][0]:
# e.append(d[i])
# else:
# if len(e) != 0:
# e.append(d[i])
# g3(e, ans)
# e = []
# if i == 0:
# return
# else:
# ans.append(d[i][1])
#
#
# def g3(e, ans):
# l = len(e)
# e.sort()
# for i in range(l):
# ans.append(e[i][1])
#
#
# def solution(numbers):
# answer = 0
# k = len(numbers)
# numbers1 = [0] * k
# for i in range(k):
# numbers1[i] = int(numbers[i])
# numbers1.sort()
# a = []
# for i in range(k):
# if numbers1[i] < 10:
# v = [numbers1[i], numbers1[i]]
# a.append(v)
# elif numbers1[i] < 100:
# v = [numbers1[i] // 10, numbers1[i]]
# a.append(v)
# elif numbers1[i] < 1000:
# v = [numbers1[i] // 100, numbers1[i]]
# a.append(v)
# else:
# v = [numbers1[i] // 1000, numbers1[i]]
# a.append(v)
# a.sort()
# # print(a)
# b = []
# ans = []
# for i in range(k - 1, -1, -1):
# if i != 0 and a[i][0] == a[i - 1][0]:
# b.append(a[i])
# else:
# if len(b) != 0:
# b.append(a[i])
# g(b, ans)
# b = []
# if i == 0:
# break
# else:
# ans.append(a[i][1])
# # print(ans)
# for i in range(len(ans)):
# if ans[i] < 10:
# answer = answer * 10 + ans[i]
# elif ans[i] >= 10 and ans[i] < 100:
# answer = answer * 100 + ans[i]
# elif ans[i] >= 100 and ans[i] < 1000:
# answer = answer * 1000 + ans[i]
# else:
# answer = answer * 10000 + ans[i]
#
# return str(answer)
def g(b, ans):
l = len(b)
for i in range(l):
if b[i][1] < 10:
b[i][0] = b[i][1]
elif b[i][1] >= 10 and b[i][1] < 100:
b[i][0] = b[i][1] % 10
elif b[i][1] >= 100 and b[i][1] < 1000:
b[i][0] = (b[i][1] % 100 - b[i][1] % 10) // 10
else:
b[i][0] = 0
b.sort()
c = []
for i in range(l - 1, -1, -1):
if i != 0 and b[i][0] == b[i - 1][0]:
c.append(b[i])
else:
if len(c) != 0:
c.append(b[i])
g1(c, ans)
c = []
if i == 0:
return
else:
ans.append(b[i][1])
def g1(c, ans):
l = len(c)
for i in range(l):
if c[i][1] < 10:
c[i][0] = c[i][1]
elif c[i][1] >= 10 and c[i][1] < 100:
c[i][0] = c[i][1] % 10
elif c[i][1] >= 100 and c[i][1] < 1000:
c[i][0] = c[i][1] % 10
else:
c[i][0] = 0
c.sort()
d = []
for i in range(l - 1, -1, -1):
if i != 0 and c[i][0] == c[i - 1][0]:
d.append(c[i])
else:
if len(d) != 0:
d.append(c[i])
g2(d, ans)
d = []
if i == 0:
return
else:
ans.append(c[i][1])
def g2(d, ans):
l = len(d)
for i in range(l):
if d[i][1] < 10:
d[i][0] = d[i][1]
elif d[i][1] >= 10 and d[i][1] < 100:
d[i][0] = d[i][1] // 10
elif d[i][1] >= 100 and d[i][1] < 1000:
d[i][0] = d[i][1] // 100
else:
d[i][0] = 0
d.sort()
e = []
for i in range(l - 1, -1, -1):
if i != 0 and d[i][0] == d[i - 1][0]:
e.append(d[i])
else:
if len(e) != 0:
e.append(d[i])
g3(e, ans)
e = []
if i == 0:
return
else:
ans.append(d[i][1])
def g3(e, ans):
l = len(e)
e.sort()
for i in range(l):
ans.append(e[i][1])
def solution(numbers):
answer = 0
k = len(numbers)
numbers1 = [0] * k
for i in range(k):
numbers1[i] = int(numbers[i])
numbers1.sort()
a = []
for i in range(k):
if numbers1[i] < 10:
v = [numbers1[i], numbers1[i]]
a.append(v)
elif numbers1[i] < 100:
v = [numbers1[i] // 10, numbers1[i]]
a.append(v)
elif numbers1[i] < 1000:
v = [numbers1[i] // 100, numbers1[i]]
a.append(v)
else:
v = [numbers1[i] // 1000, numbers1[i]]
a.append(v)
a.sort()
# print(a)
b = []
ans = []
for i in range(k - 1, -1, -1):
if i != 0 and a[i][0] == a[i - 1][0]:
b.append(a[i])
else:
if len(b) != 0:
b.append(a[i])
g(b, ans)
b = []
if i == 0:
break
else:
ans.append(a[i][1])
# print(ans)
for i in range(len(ans)):
if ans[i] < 10:
answer = answer * 10 + ans[i]
elif ans[i] >= 10 and ans[i] < 100:
answer = answer * 100 + ans[i]
elif ans[i] >= 100 and ans[i] < 1000:
answer = answer * 1000 + ans[i]
else:
answer = answer * 10000 + ans[i]
return str(answer)
na = list(input().split())
print(solution(na))