from collections import defaultdict N, M = map(int, input().split()) points = defaultdict(list) for _ in range(M): a, b, c = map(int, input().split()) points[a].append((b, c)) ans = 0 def dfs(arr, score): if len(arr) == N: global ans ans = max(ans, score) return for j in range(N): if j in arr: continue val = 0 for b, c in points[j]: if b not in arr: val += c dfs(arr + [j], score + val) dfs([], 0) print(ans)