import itertools n,m = map(int,input().split()) a = [] for i in range(m): temp = list(map(int,input().split())) a.append(temp) seq = [] for i in range(n): seq.append(i) c = list(itertools.permutations(seq)) score = [] k = len(c) for p in range(k): total = 0 for i in range(m): if c[p].index(a[i][0]) < c[p].index(a[i][1]): total += a[i][2] score.append(total) print(max(score))