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())) res = linprog(c, A_ub=a_ub, b_ub=b_ub, method='revised simplex') print(sum(map(lambda x:int(round(x,0)), res.x)))