from itertools import permutations n,m = list(map(int, input().split(' '))) scores = [] for i in range(n): r = [0] * n scores.append(r) for i in range(m): left, right, score = list(map(int, input().split(' '))) scores[left][right] = score ms = -1 for p in permutations(range(n)): score = 0 for i in range(n-1): for j in range(i+1,n): score += scores[p[i]][p[j]] ms = max(ms, score) print(ms)