from scipy.optimize import linprog p, q, r, s, t = input().split() c = [-1, -1, -1, -1, -1] A = [[1, 1, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 1, 1], [1, 0, 0, 1, 1], [1, 1, 0, 0, 1]] b = [int(p), int(q), int(r), int(s), int(t)] bounds =[ (0, None), (0, None), (0, None), (0, None), (0, None), ] res = linprog(c, A_ub=A, b_ub=b, bounds=bounds) print(-int(res.fun))