N,M = map(int,input().split()) G = [[] for _ in range(N)] for _ in range(M): a,b,c = map(int,input().split()) a -= 1 b -= 1 G[a].append((b,c)) G[b].append((a,c)) inf = 10 ** 8 dp = [[0] * N for _ in range(1 << N)] for j in range(N): mask = 1 << j dp[mask][j] = 0 for bit in range(1 << N): for j in range(N): mask = 1 << j if bit & mask == 0:continue for v,c in G[j]: maskv = 1 << v if bit & maskv:continue dp[bit ^ maskv][v] = max(dp[bit ^ maskv][v],dp[bit][j] + c) _max = 0 for bit in range(1 << N): for j in range(N): if dp[bit][j] > _max: _max = dp[bit][j] print(_max)