from scipy.optimize import linprog u,v,w,x,y = map(int,input().split()) c = [-1]*5 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") print(int(-ans.fun))