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): score += scores[p[i]][p[i+1]] ms = max(ms, score) print(ms)