import sys
a = list(sys.stdin.read().split())
t = [[int(n[:-1] or 0), int(n[-1])] for n in a]
t = list(zip(*t))
ans = (sum(t[0]) + (len(u := list(filter(lambda n: n > 0, t[1]))) - 1)) * 10 + min(u)
print(ans)