from math import ceil
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

def f(S,v):
    if S:
        res = []
        for s in S:
            res += f(S - {s}, 10 * ceil(v / 10) + s)
        return res
    else:
        return [v]
ans = min(f({a,b,c,d,e},0))
print(ans)