#!/usr/bin/env python3.8 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% N, M = map(int, readline().split()) m = map(int, read().split()) ABC = zip(m, m, m) # %% INF = 10 ** 9 dist = [[-INF] * N for _ in range(N)] for a, b, c in ABC: a -= 1 b -= 1 if dist[a][b] < c: dist[a][b] = c dist[b][a] = c # %% dp = [[-INF] * (1 << N) for _ in range(N)] for i in range(N): dp[i][1 << i] = 0 for n in range(1 << N): for j in range(N): if n & (1 << j): continue m = n | (1 << j) x = dp[j][m] for i in range(N): y = dp[i][n] + dist[i][j] if x < y: x = y dp[j][m] = x # %% answer = 0 for i in range(N): x = max(dp[i]) if answer < x: answer = x print(answer)