from collections import defaultdict import sys sys.setrecursionlimit(10 ** 6) def dfs(i, s=0, d=0): s += 2 ** i # print(i,format(s,"b"),d,memo) if memo[i][s] > -1: return memo[i][s]+d memo[i][s]=-d mx = d for ki in to[i]: if (s >> ki) & 1: continue tmp = dfs(ki, s, d + ds[i][ki]) if tmp > mx: mx = tmp memo[i][s] += mx return mx n, m = map(int, input().split()) to = defaultdict(list) ds = [[-1] * n for _ in range(n)] memo = [[-1] * (2 ** n) for _ in range(n)] for _ in range(m): a, b, c = map(int, input().split()) a -= 1 b -= 1 to[a].append(b) to[b].append(a) ds[a][b] = ds[b][a] = max(ds[a][b], c) print(max(dfs(i) for i in range(n)))