import numpy as np from scipy.optimize import linprog u, v, w, x, y = map(int, input().split()) # 最小化する目的関数 = -x1 - x2 - x3 - x4 - x5 c = [-1, -1, -1, -1, -1] # 下 2 行で, A [x1; x2; x3; x4; x5] <= b A = [[1, 0, 0, 1, 1], [1, 1, 0, 0, 1], [1, 1, 1, 0, 0], [0, 1, 1, 1, 0], [0, 0, 1, 1, 1]] # 決定変数の係数 b = [u, v, w, x, y] # 値域制約 x1 = (0, None) x2 = (0, None) x3 = (0, None) x4 = (0, None) x5 = (0, None) # 最小化問題として解く ans = linprog(c, A_ub=A, b_ub=b, bounds=(x1, x2, x3, x4, x5), method='simplex') # 最大化問題の解(最小化問題の解×(-1)) ans = -ans.fun if ans > pow(2, 50): print(int(ans - 0.5)) else: print(int(ans + 0.001))