from itertools import permutations N, M = map(int, input().split()) S = [] for _ in range(M): s = list(map(int, input().split())) S.append(s) A = [i for i in range(N)] MAX = 0 for v in permutations(A): SUM = 0 for s in S: index1 = v.index(s[0]) index2 = v.index(s[1]) if index1 < index2: SUM += s[2] MAX = max(MAX, SUM) print(MAX)