n, m = map(int, input().split()) score = [[0]*n for _ in range(n)] for _ in range(m): a, b, s = map(int, input().split()) score[a][b] = s dp = [[0]*n for _ in range(1 << n)] for s in range(1 << n): for v in range(n): for u in range(n): if (s >> u) & 1==0: continue if (s >> v) & 1 == 0: if dp[s][u]+score[u][v] > dp[s | (1 << v)][v]: dp[s | (1 << v)][v] = dp[s][u]+score[u][v] print(max(dp[(1 << n)-1]))