from itertools import permutations N,M = map(int,input().split()) XYS = [list(map(int,input().split())) for _ in range(M)] ans = 0 for L in permutations(range(N),N): tmp = 0 for x,y,s in XYS: if L[x] < L[y]: tmp += s ans = max(ans,tmp) print(ans)