N,M = map(int,input().split()) items = [list(map(int,input().split())) for _ in range(M)] ss = [] def change(n,*args): b = list(args) c = list(args) if n < N: for i in range(N): if b[n] == -1 and i not in b: c[n] = i change(n+1,*c) else: score = 0 for j in range(M): if b[items[j][0]] < b[items[j][1]]: score += items[j][2] global ss ss.append(score) a = [-1]*N change(0,*a) print(max(ss))