import sys; input = sys.stdin.buffer.readline sys.setrecursionlimit(10**7) from collections import defaultdict con = 10 ** 9 + 7; INF = float("inf") import copy import itertools def getlist(): return list(map(int, input().split())) #処理内容 def main(): A = getlist() seq = [0, 1, 2, 3, 4] P = list(itertools.permutations(seq, 5)) ans = 0 N = len(P) for i in range(N): val = 0 B = copy.copy(A) s = P[i] for j in range(5): itr = s[j] m = min(B[(itr - 1) % 5], B[itr % 5], B[(itr + 1) % 5]) B[(itr - 1) % 5] -= m B[itr % 5] -= m B[(itr + 1) % 5] -= m val += m ans = max(ans, val) print(ans) if __name__ == '__main__': main()