score = [0] * 1000 N, M = map(int, raw_input().split()) for t in xrange(M): a, b, c = map(int, raw_input().split()) score[a * N + b] = c def solve(m): res = 0 for i in xrange(0, N): if (m >> i) & 1 == 0: tmp = 0 for j in xrange(0, N): if (m >> j) & 1 == 1: tmp += score[j * N + i] res = max(res, tmp + solve(m | (1 << i))) return res print solve(0)