import itertools item1 = [] item2 = [] N, M = list(map(int, input().split())) score_book = [[0 for i in range(N)] for j in range(N)] for n in range(M): i, j, k = list(map(int, input().split())) score_book[i][j] = k #全てのパターンを網羅する。 permu = list(itertools.permutations([i for i in range(N)], N)) combi_len = len(permu) #全通りのスコアを入れる配列を作る score_table = [0] * combi_len for k, co in enumerate(permu): for i in range(N-1): for j in range(i + 1, N): score_table[k] = score_table[k] + score_book[co[i]][co[j]] i += i print(max(score_table))