from itertools import permutations n, m = [int(s) for s in input().split()] table = [] for i in range(m): table.append([int(s) for s in input().split()]) max_score = 0 for perm in permutations(range(n), n): score = 0 for i1, i2, sc in table: if perm[i1] < perm[i2]: score += sc max_score = max(max_score, score) print(max_score)