N, M = map(int, input().split()) score = [[0] * N for i in range(N)] for i in range(M): a, b, s = map(int, input().split()) score[a][b] += s from itertools import permutations l = [i for i in range(N)] ans = 0 for p in permutations(l): p = list(p) s = 0 for i in range(N): for j in range(i + 1, N): s += score[p[i]][p[j]] ans = max(ans, s) print(ans)