from itertools import permutations N, M = list(map(int, input().split(' '))) S = [] for i in range(N): S.append([0 for _ in range(N)]) for i in range(M): f, t, s = list(map(int, input().split(' '))) S[f][t] = s solution = -1 for p in permutations([i for i in range(N)]): score = 0 for i in range(N): for j in range(i+1, N): score += S[p[i]][p[j]] solution = max(solution, score) print(solution)