N,M = map(int,input().split()) iis = [tuple(map(int,input().split())) for _ in range(M)] from itertools import permutations ans = 0 for p in permutations([i for i in range(N)]): tmp = 0 for i1,i2,s in iis: if p[i1-1] < p[i2-1]: tmp += s ans = max(ans,tmp) print(ans)