import itertools N, M = map(int,input().split()) items = [] for i in range(1,M+1): items.append(list(map(int,input().split()))) max = 0 for v in list(itertools.permutations([x for x in range(N)])): sum = 0 for item in items: if v.index(item[0]) < v.index(item[1]): sum += item[2] if max < sum: max = sum print(max)