from itertools import permutations N, M = map(int, input().split()) table = [tuple(map(int, input().split())) for j in range(M)] ans = 0 for pos in permutations(range(N)): tot = 0 for item1, item2, score in table: if pos[item1] < pos[item2]: tot += score ans = max(ans, tot) print(ans)