# -*- coding: utf-8 -*- N, M = map(int, raw_input().split()) l = [] for i in xrange(M): k = map(int, raw_input().split()) l.append(k) def score(m): score = 0 for k in l: if m[k[0]] < m[k[1]]: score += k[2] return score maxs = 0 def dp(l, m): if len(l) == 0: return score(m) mx = 0 for i in xrange(len(l)): froml = list(l) tol = list(m) tol.append(froml.pop(i)) c = dp(froml, tol) mx = max(mx, c) return mx start = [i for i in xrange(N)] print dp(start, [])