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, method='revised simplex') frac = -res.fun - int(-res.fun) print(int(-res.fun) + (frac > 0.9999999))