import itertools def main(): N,M=map(int,input().split()) pa=[[0]*N for _ in range(N)] for _ in range(M): a,b,c=map(int,input().split()) pa[a][b]=c Max=0 for p in itertools.permutations(range(N)): sum=0 for i in range(N-1): for j in range(i+1,N): x,y=p[i],p[j] sum+=pa[x][y] Max=max(Max,sum) print(Max) main()