import itertools N,M = map(int,input().split()) S = [tuple(map(int,input().split())) for i in range(M)] score = 0 for item in itertools.permutations(range(N)): total = 0 for a, b, s in S: if (item.index(a) < item.index(b)): total += s else: pass if (total > score): score = total print(score)