# coding: utf-8 from itertools import permutations from itertools import combinations N, M = map(int, input().split()) scores = [[0] * N for __ in range(N)] for __ in range(M): i1, i2, sc = map(int, input().split()) scores[i1][i2] = sc max_score = 0 for per in permutations(range(N)): tmp_score = 0 for i in range(N): for j in per[i:]: tmp_score += scores[i][j] max_score = max(max_score, tmp_score) print(max_score)