import itertools n, m = [int(x) for x in input().split()] table = [] for i in range(n): table += [[0] * n] for i in range(m): it1, it2, sc = [int(x) for x in input().split()] table[it1][it2] = sc res = 0 for v in itertools.permutations(range(n)): score = 0 for i in range(1, len(v)): for j in range(0, i): score += table[v[j]][v[i]] res = max(score, res) print(res)