import itertools N, M = map(int, input().split()) score = [list(map(int, input().split())) for _ in range(M)] A = list(itertools.permutations(list(range(N)))) B = [0]*len(A) for i in range(M): K = score[i][0] L = score[i][1] T = score[i][2] for j in range(len(A)): if A[j].index(K) > A[j].index(L): B[j] += T print(max(B))