import itertools n, m = map(int, input().split()) score = [[0 for _ in range(n)] for _ in range(n)] for i in range(m): x, y, p = map(int, input().split()) score[x][y] = p maxs = 0 for i in itertools.permutations(range(n)): t = 0 for j in range(n-1): for k in range(j+1, n): t += score[i[j]][i[k]] maxs = max(maxs, t) print(maxs)