import itertools N, M = map(int, input().split()) item1 = [0] * M item2 = [0] * M score = [0] * M max_score = 0 sheat = [] for p in range(N): l = [] for q in range(N): l.append(0) sheat.append(l) for i in range(M): item1[i], item2[i], score[i] = map(int, input().split()) sheat[item1[i]][item2[i]] = score[i] perm = [i for i in range(N)] p = list(itertools.permutations(perm)) for ichi in p: temp = 0 for i in range(M): if ichi[item1[i]-1] < ichi[item2[i]-1]: temp += score[i] if temp > max_score: max_score = temp print(max_score)