from scipy.optimize import linprog c = [-1,-1,-1,-1,-1] a_ub = [[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_ub = list(map(int, input().split())) bounds = (0, None) res = linprog(c, A_ub=a_ub, b_ub=b_ub, bounds=bounds) print(int(round(-res.fun,0)))