from itertools import permutations def solve(): N, M = map(int, input().split()) ss = [[0 for _ in range(N)] for _ in range(N)] for i in range(M): i1, i2, s = map(int, input().split()) ss[i1][i2] = s ma = 0 for l in permutations(range(N)): s = 0 for i in range(N): for j in range(i): if l[i] > l[j]: s += ss[l[i]][l[j]] else: s += ss[l[j]][l[i]] ma = max(ma, s) print(ma) if __name__ == '__main__': solve()