from copy import deepcopy N, M = map(int, input().split()) item1 = [0] * M item2 = [0] * M score = [0] * M sheat = [] max_score = 0 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] def dp(check): if len(check) == 0: return 0 elif len(check) == 1: return 0 else: tempmax = 0 for i in check: temp = deepcopy(check) temp.remove(i) temp2 = 0 for p in temp: temp2 += sheat[p][i] temp2 += dp(temp) if tempmax < temp2: tempmax = temp2 return tempmax l = [i for i in range(N)] print(dp(l))