import itertools N,M=map(int,input().split()) t=[[0 for _ in range(N)] for _ in range(N)] for i in range(M): f,s,p=map(int,input().split()) t[f][s]=p l=list(map(list,itertools.permutations(range(N)))) n=len(l) d=[0 for _ in range(n)] for i in range(n): for j in l[i]: for k in l[i][l[i].index(j):]: d[i]+=t[j][k] print(max(d))