# coding: utf-8 from itertools import permutations from itertools import combinations N, M = map(int, input().split()) item1 = [] item2 = [] score = [] score_dict = dict() for __ in range(M): i1, i2, sc = map(int, input().split()) score_dict[(i1, i2)] = sc l_per = list(permutations(range(N))) l_score = [] for per in l_per: a_score = 0 for i in list(combinations(per, 2)): if i in score_dict: a_score += score_dict[i] l_score.append(a_score) print(max(l_score))