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): for j in range(len(A)): if A[j].index(score[i][0]) > A[j].index(score[i][1]): B[j] += score[i][2] print(max(B))